[英]When using vue.js, the radio button is not mapped to the v-model normally if repeated with v-for
I'd like to make a big change to this code.我想对这段代码做一个大的改变。 But it doesn't work the way I want it to.
但它并没有按照我想要的方式工作。
<td>
<label>
<input type="radio" v-model="options.prdtType" value="CODE001">
<i></i>
<span class="txt">A</span>
</label>
<label>
<input type="radio" v-model="options.prdtType" value="CODE002">
<i></i>
<span class="txt">B</span>
</label>
<label>
<input type="radio" v-model="options.prdtType" value="CODE003">
<i></i>
<span class="txt">C</span>
</label>
</td>
And this is the code I changed.这是我更改的代码。
data: {
codeVo: {
codeObsTypeList: [],
},
...
userParam: {
prdtType: '',
}
...
<td>
<label class="radio_custom" v-for="(item, index) in codeVo.codeObsTypeList" :key="index">
<input type="radio" v-model="userParam.prdtType" v-value="item.key">
<i></i>
<span class="txt" v-text="item.txt"></span>
</label>
</td>
And codeVo.codeObsTypeList is like this.而codeVo.codeObsTypeList就是这样的。
You can v-value="item.key"
change to :value="item.key
.您可以将
v-value="item.key"
更改为:value="item.key
。
<td>
<label class="radio_custom" v-for="(item, index) in codeVo.codeObsTypeList" :key="index">
<input type="radio" v-model="userParam.prdtType" :value="item.key">
<i></i>
<span class="txt" v-text="item.txt"></span>
</label>
</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.