export const Debounce = (fn,time) =>{
// fn 触发的方法
// 时间
const delay = time || 500
let timer
return function(){
const args = arguments
if(timer){
clearTimeout(timer)
}
const callNow = !timer
timer = setTimeout(()=>{
timer = null
},delay)
if(callNow) fn.apply(this,args)
}
}
javaScript 函数防抖
最新推荐文章于 2023-03-22 09:06:17 发布