Appearance
useSyncRef
▸ useSyncRef(source, options?): Ref<any>
Two-way refs synchronization.
参数
| Name | Type | Description |
|---|---|---|
source | Ref<any> | 要同步的源引用。 |
options | any | 定义如何同步的选项。 |
返回值
Ref<any>
- 与源引用同步的新引用。
See
示例
ts
// 之前
const a = ref('a')
const b = ref('b')
const stop = syncRef(a, b)
// 现在
const a = ref('a')
const b = useSyncRef(a)
b.value = 'foo'
console.log(a.value) // foo
a.value = 'bar'
console.log(b.value) // bar