mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(@vant/use): invalid watch source (#9095)
This commit is contained in:
parent
103929ae3d
commit
f550c634e3
@ -1,4 +1,4 @@
|
|||||||
import { Ref, unref, onUnmounted, onDeactivated, watch } from 'vue';
|
import { Ref, watch, isRef, unref, onUnmounted, onDeactivated } from 'vue';
|
||||||
import { onMountedOrActivated } from '../onMountedOrActivated';
|
import { onMountedOrActivated } from '../onMountedOrActivated';
|
||||||
import { inBrowser } from '../utils';
|
import { inBrowser } from '../utils';
|
||||||
|
|
||||||
@ -65,8 +65,10 @@ export function useEventListener(
|
|||||||
onDeactivated(() => remove(target));
|
onDeactivated(() => remove(target));
|
||||||
onMountedOrActivated(() => add(target));
|
onMountedOrActivated(() => add(target));
|
||||||
|
|
||||||
|
if (isRef(target)) {
|
||||||
watch(target, (val, oldVal) => {
|
watch(target, (val, oldVal) => {
|
||||||
remove(oldVal);
|
remove(oldVal);
|
||||||
add(val);
|
add(val);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user