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>
扫描二维码关注公众号,回复:
3625778 查看本文章
</table>
//以上数据类型,让v-model无法绑定数据。
解决:改变数据类型:
childrenList: [{sku0:{sku:''},quantity0:{quantity:1},start_price0:{start_price:''}}],
//这样就可以了。