我正在使用 Vue3 组合 API。我有一个需要与商店同步的输入字段,以防商店中的数据发生变化,它应该被更新
代码
const store = useStore()
const savedAge = computed(() => store.state.profile.age)
// The saved is async and can be updated at anytime in store
const age = ref(savedAge.value)
<!-- template -->
<input v-model="age" /> // here the age is null event if savedAge value has updated in store
请注意,我不希望与 store 进行两种方式绑定,如果 store 值已更新,我希望我的响应属性更新
我如何实现这一目标?