Browse Source

[style] amount

wenliming 3 years ago
parent
commit
446ec55962
4 changed files with 24 additions and 2 deletions
  1. 15 1
      components/FontAmount.vue
  2. 2 1
      nuxt.config.js
  3. 1 0
      package.json
  4. 6 0
      plugins/antd-design-vue.js

+ 15 - 1
components/FontAmount.vue

@@ -1,5 +1,9 @@
 <template>
-    <span :style="{ fontSize: amount_font_size + 'px' }">{{ amount }}</span>
+    <span :style="{ fontSize: amount_font_size + 'px' }">
+        <a-tooltip :title="amount">
+            {{ getBit(amount) }}
+        </a-tooltip>
+    </span>
 </template>
 
 <script>
@@ -47,6 +51,16 @@ export default {
         setFontSize() {
             let _num = parseInt(this.width / this.amount.length);
             this.amount_font_size = _num < this.fontSize ? _num : this.fontSize;
+        },
+        getBit (value) {
+            const reg = /([0-9]+\.[0-9]{4})[0-9]*/;
+            if(value) {
+                let str = value.toString();
+                str = str.replace(reg,"$1");
+                return str;
+            } else {
+                return value;
+            }
         }
     }
 }

+ 2 - 1
nuxt.config.js

@@ -24,7 +24,8 @@ export default {
 
   // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
   plugins: [
-    'plugins/vant'
+    'plugins/vant',
+    'plugins/antd-design-vue',
   ],
 
   // Auto import components: https://go.nuxtjs.dev/config-components

+ 1 - 0
package.json

@@ -22,6 +22,7 @@
     "test": "jest"
   },
   "dependencies": {
+    "ant-design-vue": "1.7.8",
     "axios": "^0.26.1",
     "bootstrap": "^4.6.1",
     "bootstrap-vue": "^2.21.2",

+ 6 - 0
plugins/antd-design-vue.js

@@ -0,0 +1,6 @@
+
+import Vue from 'vue'
+import {Tooltip} from 'ant-design-vue'
+import 'ant-design-vue/dist/antd.css';
+
+Vue.use(Tooltip);