fix: 优化watch 修改编辑用户弹窗样式
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// src/hooks/useDebounce.ts
|
||||
import { watch, onUnmounted, Ref } from 'vue';
|
||||
import { onUnmounted, Ref } from 'vue';
|
||||
import { useState } from './useState';
|
||||
import { useEffect } from './useEffect';
|
||||
|
||||
export interface UseDebounceOptions {
|
||||
delay?: number;
|
||||
@@ -40,7 +41,7 @@ export function useDebounce<T>(source: Ref<T>, options: number | UseDebounceOpti
|
||||
isFirstCall = true;
|
||||
};
|
||||
|
||||
watch(source, () => {
|
||||
useEffect(() => {
|
||||
setIsPending(true);
|
||||
|
||||
// 处理 maxWait
|
||||
@@ -61,7 +62,9 @@ export function useDebounce<T>(source: Ref<T>, options: number | UseDebounceOpti
|
||||
updateValue();
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
|
||||
return clearTimers;
|
||||
}, [source]);
|
||||
|
||||
// 卸载
|
||||
onUnmounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user