import Vue from "vue";
// vue自定义指令防抖
Vue.directive("antiShake", {
bind: function(el, binding, vnode) {
let { delay, fn } = binding.value; //参数:时间,执行函数
delay = delay ? delay : 500;
let timer = null;
el.addEventListener("click", () => {
timer && clearTimeout(timer);
timer = setTimeout(fn, delay);
});
}
});