vue+elementUI中单选框el-radio设置默认值
- 如果后台返回的单选框的值是number:单选框的lable需要设置成 :lable=‘0’;如下:
<el-form-item label="仿牌选项:" prop="ifCod" size="mini" class=\'form-label\'>
<div id=\'radio\' >
<el-radio class=\'m0\' :disabled="disable" v-model="form.ifCod" :label="0" >普货</el-radio>
<el-radio class=\'m0\' :disabled="disable" v-model="form.ifCod" :label="1" >仿牌</el-radio>
</div>
</el-form-item>
data(){
return {
form:{
ifCode:0
}
}
}
<el-form-item label="仿牌选项:" prop="ifCod" size="mini" class=\'form-label\'>
<div id=\'radio\' >
<el-radio class=\'m0\' :disabled="disable" v-model="form.ifCod" label="0" >普货</el-radio>
<el-radio class=\'m0\' :disabled="disable" v-model="form.ifCod" label="1" >仿牌</el-radio>
</div>
</el-form-item>
data(){
return {
form:{
ifCode:\'0\'
}
}
}
唯一标识一个单选框
<!--
若标签内部没有定义单选框名字,则会用label值充当,因为change事件只能传label值,所以此时可能无法唯一标识该单选框
-->
<el-radio label="提前天数:" v-model="airRuleForm.radio1" @change="getRadioValue"> </el-radio>
<!--
若标签内部定义了单选框名字,label值则可定义成唯一标识该单选框的身份id
-->
<el-radio label="radio1" v-model="airRuleForm.radio1" @change="getRadioValue">提前天数</el-radio>