mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Fix:修复debounce方法逻辑错误的问题
This commit is contained in:
parent
e228386222
commit
407b86c5ee
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user