debounce(fn, delay=500) {
debounce(fn, delay=500) {
let timer;
return function() {
const that = this;
const args = arguments;
if(timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
timer = null;
fn.apply(that, args);
}, delay)
}
}
防抖函数