节流

2022-03-29  本文已影响0人  bryan_liu
//  func需要执行的函数
//  wait延迟执行时间
function throttle(func,wait) {
  let timeout
  return function () {
    let context = this
    let args = arguments
    if(!timeout) {
      timeout = setTimeout(function(){
        timeout = null
        func.apply(context ,args )
      },wait)
    }
  }
}
上一篇 下一篇

猜你喜欢

热点阅读