关于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,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:''}}],

//这样就可以了。

猜你喜欢

转载自blog.csdn.net/qq_40101922/article/details/82347632