逐行解释JS防抖及防抖的使用
debounce(func, waitTime) {
let timer = null;
return function() {
const context = this;
const args = arguments;
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => func.apply(context, args), waitTime);
}
}
原创
2021-02-24 01:09:15 ·
2073 阅读 ·
9 评论