Jelajahi Sumber

perf: replace `onUnMounted` to `tryOnScopeDispose` (#7747)

* perf: replace `onUnMounted` to `tryOnScopeDispose`

* perf: replace `onUnMounted` to `tryOnScopeDispose`
橙子 2 bulan lalu
induk
melakukan
4a69c9e665
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 3 3
      packages/effects/hooks/src/use-hover-toggle.ts

+ 3 - 3
packages/effects/hooks/src/use-hover-toggle.ts

@@ -2,11 +2,11 @@ import type { Arrayable, MaybeElementRef } from '@vueuse/core';
 
 import type { Ref } from 'vue';
 
-import { computed, effectScope, onUnmounted, ref, unref, watch } from 'vue';
+import { computed, effectScope, ref, unref, watch } from 'vue';
 
 import { isFunction } from '@vben/utils';
 
-import { useElementHover } from '@vueuse/core';
+import { tryOnScopeDispose, useElementHover } from '@vueuse/core';
 
 interface HoverDelayOptions {
   /** 鼠标进入延迟时间 */
@@ -151,7 +151,7 @@ export function useHoverToggle(
     },
   };
 
-  onUnmounted(() => {
+  tryOnScopeDispose(() => {
     clearTimers();
     // 停止监听器
     stopWatcher();