From 7df5825a218028cd336e792e2ee662d49aa6f2fd Mon Sep 17 00:00:00 2001 From: sc Date: Wed, 16 Jun 2021 13:16:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=9B=86=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8D=83=E5=88=86=E7=AC=A6=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 4 ++++ src/utils/tool.js | 10 ++++++++++ src/views/other/directive.vue | 13 +++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 042cfedf..580a72bf 100644 --- a/src/main.js +++ b/src/main.js @@ -21,6 +21,7 @@ import auth from './directives/auth' const app = createApp(App); +//挂载全局对象 app.config.globalProperties.$CONFIG = config; app.config.globalProperties.$TOOL = tool; app.config.globalProperties.$HTTP = http; @@ -31,6 +32,7 @@ app.use(store); app.use(router); app.use(ElementPlus, {size: 'small', locale: locale}); +//注册全局组件 app.component('scTable', scTable); app.component('scFilterBar', scFilterBar); app.component('scUpload', scUpload); @@ -38,6 +40,8 @@ app.component('scUploadMultiple', scUploadMultiple); app.component('scFormTable', scFormTable); app.component('scTableSelect', scTableSelect); +//注册全局指令 app.directive('auth', auth) +//挂载app app.mount('#app'); diff --git a/src/utils/tool.js b/src/utils/tool.js index 03526678..72fb9ede 100644 --- a/src/utils/tool.js +++ b/src/utils/tool.js @@ -71,6 +71,16 @@ const tool = { } } return fmt; + }, + /* 千分符 */ + thousands(num){ + num = num + ''; + if(!num.includes('.')){ + num += '.' + } + return num.replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) { + return $1 + ','; + }).replace(/\.$/, ''); } } diff --git a/src/views/other/directive.vue b/src/views/other/directive.vue index 74523f4c..fe6a4347 100644 --- a/src/views/other/directive.vue +++ b/src/views/other/directive.vue @@ -1,15 +1,24 @@