我将 Vuex 与我的 Vue 组件一起使用。当我的组件具有可编辑的静态字段时,可以使用计算属性轻松处理它们:
computed: {
text: {
get() {
return ...
},
set(value) {
this.$store.commit...
},
},
},
<input type="text" v-model="text">
但是,当我呈现需要绑定的选项列表时,应该怎么做呢?
options = [
{
value: ...,
text: ...,
},
{
value: ...,
text: ...,
},
...
];
<input type="text" v-model="option.text" v-for="option in options">