我想将数组中的字符串添加到v-model中,如下所示:
<div v-for="(item, index) in items" :key="index">
<input :v-model="item.key" />
</div>但是这段代码不能工作,经过多次搜索,我没有找到正确的方法
发布于 2020-03-31 19:32:42
请参阅此fiddle for a working example。v-model不需要:放在前面。
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
items: [{
key: "test one"
},
{
key: "test two"
},
{
key: "test three"
}]
}
})和dom:
<script src="https://unpkg.com/vue"></script>
<div id="app">
<p>{{ message }}</p>
<div v-for="(item, index) in items" :key="index">
<input v-model="item.key" />
</div>
</div>文档链接:Vue form bindings
https://stackoverflow.com/questions/60949428
复制相似问题