节流

作者: bryan_liu | 来源:发表于2022-03-29 11:36 被阅读0次
//  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)
    }
  }
}

相关文章

网友评论

      本文标题:节流

      本文链接:https://www.haomeiwen.com/subject/dbuvjrtx.html