项目全局防抖
//防抖处理-立即执行
const on = Vue.prototype.$on
Vue.prototype.$on = function (event, func) {
let timer
let flag = true
let newFunc = func
if (event === 'click') {
newFunc = function () {
if (flag) {
func.apply(this, arguments)
flag = false
}
clearTimeout(timer)
timer = setTimeout(function () {
flag = true
}, 500)
}
}
on.call(this, event, newFunc)
}