自定义命令统一管理,装饰器统一管理

This commit is contained in:
aixianling
2023-03-22 15:41:27 +08:00
parent 8f2ac6ed81
commit 2129a8ad8b
3 changed files with 55 additions and 17 deletions

28
ui/lib/js/directives.js Normal file
View File

@@ -0,0 +1,28 @@
const map = {
throttle: {
bind: function (el, obj) {
let timerId = null
let flag = true
el.addEventListener('input', function () {
if (!flag) return
flag = false
timerId && clearTimeout(timerId)
timerId = setTimeout(function () {
flag = true
obj.value()
}, 800)
})
}
}
}
export default {
install(Vue) {
for (const key in map) {
Vue.directive(key, map[key])
}
}
}