Files
dvcp_v2_webapp/ui/lib/js/directives.js
2023-03-22 15:41:27 +08:00

29 lines
481 B
JavaScript

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])
}
}
}