<button @click="add"></button>
<tbody>
<tr v-for="item in data" >
<td >
{{item.name}}
</td>
<td >
{{item.price}}
</td>
<td >
<input name="" type="radio" >
</td>
</tr>
</tbody>
<script>
export default{
data(){
return{
data:[]
}
},
methods:{
add(){
this.data.push({name:"apple",price:"8.0", isMainProduct:""},)
}
}
}
</script>
求助,现在点击button 增加的数据的话怎么去绑定<input name="" type="radio" >,让它选中的时候isMainProduct的值为true,不选中时值为false? 请帮帮忙jiong
你可以先在你写的html的input后面添加{{isMainProduct}},
input的本身添加v-model=isMainProduct,
在js 实例里面写先写一个属性isMainProduct:false,
这样 你选中input按钮 后面的值就会相应的改变了.