【发布时间】:2018-10-02 16:55:31
【问题描述】:
我正在为选项卡式界面构建选项卡,用户可以在其中更改选项卡的标题。我想做的是这样的:
标记:
<div class="tabs" v-for="(tab, tabIndex) in tabs" :key="tab.id" >
<input type="text" v-model:value="tabs(tabIndex)">
</div>
计算属性:
computed: {
scenes2: {
get(tabIndex){
return this.$store.state.tabs[tabIndex].title
},
set(value, tabIndex){
this.$store.dispatch('setTabTitle', {value: value, tabIndex: tabIndex} )
},
},
},
这当然行不通。在这里使用 v-model 的正确方法是什么,以便我可以将 v-model 与 Vuex 状态下 tabs 数组上的相关索引相关联?
【问题讨论】:
标签: javascript vue.js