diff --git a/src/directives/modules/throttle/index.ts b/src/directives/modules/throttle/index.ts index ac3c8862..1e7f5f05 100644 --- a/src/directives/modules/throttle/index.ts +++ b/src/directives/modules/throttle/index.ts @@ -41,15 +41,16 @@ const throttleDirective: CustomDirectiveFC< throttleFunction = throttle(func, wait, Object.assign({}, options)) - useEventListener(el, trigger, throttleFunction) + cleanup = useEventListener(el, trigger, throttleFunction) }, beforeUnmount: () => { if (throttleFunction) { throttleFunction.cancel() - cleanup?.() } throttleFunction = null + + cleanup?.() }, } }