fn
useSyncRefs
v0.0.1testeddemoSyncs the value of a source ref with multiple target refs
Examples
ts
const source = ref(0);
const target1 = ref(0);
const target2 = ref(0);
useSyncRefs(source, [target1, target2]);ts
const source = ref(0);
const target1 = ref(0);
useSyncRefs(source, target1, { immediate: true });Demo
Loading demo…
Signature
ts
export function useSyncRefs<T = unknown>(
source: WatchSource<T>,
targets: Ref<T> | Array<Ref<T>>,
watchOptions: WatchOptions ={ ... }Type Parameters
T= unknownParameters
| Parameter | Type | Description |
|---|---|---|
source | WatchSource<T> | Source ref to sync |
targets | Ref<T, T> | Ref<T, T>[] | Target refs to sync |
watchOptions? | WatchOptions<boolean> | Watch options |
Returns
import("vue").WatchHandleWatch stop handle