2021年5月8日星期六

Vue ref/reactive with default value

I am using Vue3 composition API. I have an input field which needs to be in sync with store, incase the data changes in store it should be updated

Code

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    

Please note I don't want two way binding with store, I want my reactive property to update if store value has been updated

How do I achieve this?

https://stackoverflow.com/questions/67437365/vue-ref-reactive-with-default-value May 07, 2021 at 11:03PM

没有评论:

发表评论