函数防抖 - typescript
export function debounce(fn: any, t: number) {
let timeId: NodeJS.Timeout | null = null
const delay = t || 1000
return function (this: any, ...args: any) {
if(timeId) clearTimeout(timeId)
timeId = setTimeout(() => {
timeId = null
fn.apply(this, args)
}, delay)
}
}

浙公网安备 33010602011771号