节流

//  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)
    }
  }
}

你可能感兴趣的:(节流)