/* * 防抖函数,接受一个函数和一个延时时间 */ export type DebouncedFunction any> = ( ...args: Parameters ) => void export function debounce any>( func: T, delay: number ): DebouncedFunction { let timeoutId: ReturnType return (...args) => { clearTimeout(timeoutId) timeoutId = setTimeout(() => { func(...args) }, delay) } }