关于vue v-for 嵌套v-for的v-model属性绑定问题
vue v-for嵌套v-for的v-model属性绑定,如果数据类型不对,常会报错如://数据data: {childrenList: [{sku:'',quantity:1,start_price:''}],},//dom渲染<table><tr v-bind::class="c._class" v-for="(c,ind
·
vue v-for嵌套v-for的v-model属性绑定,如果数据类型不对,常会报错
如:
//数据
data: {
childrenList: [{sku:'',quantity:1,start_price:''}],
},
//dom渲染
<table>
<tr v-bind::class="c._class" v-for="(c,index) in childrenList">
<td v-for="(item,index) in c" :key="index"><input type="text" class="form-control" v-model="item[index]"></td>
</tr>
</table>
//以上数据类型,让v-model无法绑定数据。
解决:改变数据类型:
childrenList: [{sku0:{sku:''},quantity0:{quantity:1},start_price0:{start_price:''}}],
//这样就可以了。
更多推荐
已为社区贡献3条内容
所有评论(0)