单选框 点击勾选或取消赋值问题
<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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以先在你写的html的input后面添加{{isMainProduct}},
input的本身添加v-model=isMainProduct,
在js 实例里面写先写一个属性isMainProduct:false,
这样 你选中input按钮 后面的值就会相应的改变了.