function debounce(fn, delay = 500) { let timer = null return function (...args) { clearTimeout(timer) // 清除之前的延迟调用 timer = setTimeout(() => { fn.apply(this, args) // 延迟执行 }, delay) } } // 导出 export default debounce