pull/1/head
xiaozhiyong 2 years ago
parent c07e56183c
commit dc50eeea8a
  1. 27
      src/main.js
  2. 18
      src/utils/directive.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,

@ -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);
}
},
});
Loading…
Cancel
Save