Initial commit

This commit is contained in:
fengachen
2021-08-23 09:57:23 +08:00
commit 71f2a1241f
167 changed files with 75173 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
const vTrim = {
install(Vue, options) {
Vue.directive('fac', {
componentUpdated: (el, {value, modifiers}) => {
let input = el
input.oninput = (event) => {
console.log(event.target.value)
// event.target.value = event.target.value.replace(/(^\s*)|(\s*$)/g, "")
input.value = input.value.replace(/(^\s*)|(\s*$)/g, "")
}
// // 获取当前光标所在位置
// const inputSelection = input.selectionStart
// // 获取加上空格后的字符串长度
// const valueLength = input.value.length
// // 这里是去除空格,可以通过其他的正则去做其他的操作(格式化手机号啊身份证号码之类的,后续也可以通过指令传入拓展成各种格式化指令)
// let newValue = value.replace(/\s/g, '')
// if (value !== newValue) {
// input.value = newValue
// if (input.value.length !== valueLength) {
// input.selectionStart = inputSelection - 1
// input.selectionEnd = inputSelection - 1
// }
// input.dispatchEvent(new Event(modifiers.lazy ? 'change' : 'input'))
// }
}
});
}
};
export default vTrim