vue自定义指令
directives: {
debounce: {
inserted: (el, binding) => {
let timer = null;
el.addEventListener('click', () => {
console.log(binding);
if (!timer) {
el.disabled = true;
timer = setTimeout(() => {
clearTimeout(timer);
timer = null;
el.removeAttribute('disabled');
}, binding.value || 1000);
}
});
},
},
},
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18