// 防抖 // 不管怎么点击,只在delay毫秒后触发事件,delay毫秒内点击也要等到delay毫秒后再触发事件 export const debounce = (fn: Function, delay = 2000) => { let timer: any = null return (...args: any[]) => { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { fn(...args) }, delay) } }