pull/1/head
parent
c07e56183c
commit
dc50eeea8a
2 changed files with 22 additions and 23 deletions
@ -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…
Reference in new issue