From dc50eeea8a31f89ff588bb976065c5d9089dc97d Mon Sep 17 00:00:00 2001 From: xiaozhiyong <xiaozhiyong@sdxkhlw.cn> Date: Mon, 13 Feb 2023 10:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 27 ++++----------------------- src/utils/directive.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 src/utils/directive.js diff --git a/src/main.js b/src/main.js index 3f08acb..1164ab8 100644 --- a/src/main.js +++ b/src/main.js @@ -1,10 +1,8 @@ import Vue from "vue"; -import "normalize.css/normalize.css"; // A modern alternative to CSS resets - import ElementUI from "element-ui"; import "element-ui/lib/theme-chalk/index.css"; -import language from "element-ui/lib/locale/lang/zh-CN"; // lang i18n +import language from "element-ui/lib/locale/lang/zh-CN"; import "@/styles/index.scss"; // global css @@ -13,31 +11,14 @@ import store from "./store"; import router from "./router"; import * as utils from "./utils"; -import "@/icons"; // icon -import "@/permission"; // permission control +import "utils/directive"; +import "@/icons"; +import "@/permission"; Vue.use(ElementUI, { language, size: "medium" }); - Vue.config.productionTip = false; Vue.prototype.$utils = utils; -Vue.directive("checkNum", { - update(el, binding, vNode) { - if (el.children.length) { - let val = el.children[0].value; - let qualifiedNum = val - .replace(/[^\d.]/g, "") - .replace(/^\./g, "") - .replace(/\.{2,}/g, ".") - .replace(/^0{2,}/g, "0") - .replace(".", "$#$") - .replace(/\./g, "") - .replace("$#$", "."); - vNode.componentInstance.$emit("input", qualifiedNum); - } - }, -}); - new Vue({ el: "#app", router, diff --git a/src/utils/directive.js b/src/utils/directive.js new file mode 100644 index 0000000..f8a45b9 --- /dev/null +++ b/src/utils/directive.js @@ -0,0 +1,18 @@ +import Vue from "vue"; + +Vue.directive("checkNum", { + update(el, binding, vNode) { + if (el.children.length) { + let val = el.children[0].value; + let qualifiedNum = val + .replace(/[^\d.]/g, "") + .replace(/^\./g, "") + .replace(/\.{2,}/g, ".") + .replace(/^0{2,}/g, "0") + .replace(".", "$#$") + .replace(/\./g, "") + .replace("$#$", "."); + vNode.componentInstance.$emit("input", qualifiedNum); + } + }, +});