0👍
I think you can use computed
property like this:
// App.vue
<template>
<div>
<Things id="1" />
</div>
</template>
<script setup>
import Things from "./components/Things.vue"
</script>
// Things.vue
<template>
<div>
<label>
Name:
<input v-model="name">
</label>
<p>{{ name }}</p>
</div>
</template>
<script setup>
import { computed } from "vue"
import { useStore } from '@/store/index.js'
const props = defineProps({ id: { type: String, required: true } })
const store = useStore()
const name = computed({
get() {
return store.things[props.id].name
},
set(name) {
store.things[props.id].name = name
}
})
</script>
sandbox:
https://codesandbox.io/s/pinia-playground-forked-6294kh
- [Vuejs]-Wrong linkin when import index.ts file without specifying the file extension, when another index.vue file is in the same folder, using vue 3 and vite?
- [Vuejs]-Vue.js select image if one exists
Source:stackexchange.com