防抖在前端中有着很广泛的应用,为了防止短时间内同样函数不必要的大量执行,我们需要做防抖处理
function Debounce(fn, wait){
var timer = null;
if(timer){
clearTimeout(timer);
}
timer = setTimeout(()=>{
fn.apply(context, args)
},wait)
}
文章为个人学习产物,仅供参考,借鉴全网文献学习
防抖在前端中有着很广泛的应用,为了防止短时间内同样函数不必要的大量执行,我们需要做防抖处理
function Debounce(fn, wait){
var timer = null;
if(timer){
clearTimeout(timer);
}
timer = setTimeout(()=>{
fn.apply(context, args)
},wait)
}
文章为个人学习产物,仅供参考,借鉴全网文献学习