刷新频繁的防抖函数处理

防抖( debounce )

debounce(func,delay){
  let timer = null;
  return function(...args){
    if(timer) clearTimeout(timer)
    timer = setTimeout( () => {
      func.apply(this,args)
    },delay)          
  }    
}

 

posted @ 2020-05-10 23:25  lethe666  阅读(185)  评论(0)    收藏  举报