节流
directives: {
// 自定义指令
throttle: {
inserted: 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()
}, 1000)
})
}
}
},