Fix:修复debounce方法逻辑错误的问题

This commit is contained in:
街角小林
2025-01-17 17:23:55 +08:00
parent e228386222
commit 407b86c5ee

View File

@@ -297,12 +297,10 @@ export const debounce = (fn, wait = 300, ctx) => {
return (...args) => {
if (timeout) clearTimeout(timeout)
const callNow = !timeout
timeout = setTimeout(() => {
timeout = null
fn.apply(ctx, args)
}, wait)
if (callNow) fn.apply(ctx, args)
}
}