您的位置:首页 > Web前端 > Vue.js

vue elementUI 单选框默认值不选中,子组件传输数据 不展示

2020-06-04 06:10 615 查看

vue elementUI 单选框默认值不选中,子组件传输数据 不展示

1单选框默认值不选中
是因为label匹配值的问题,必须类型和值都对
:label=‘1’ 对应的是 int类型 的1
label = ‘1’ 对应的是字符串‘1’
2子组件传输数据 不展示
是因为传输速度跟不上,最好在@open或者@opened 事件里更新数据

<el-dialog :visible.sync="edit_Dialog_Flag" @close="closeDialog" width="600px" @opened="openedDialog">

这里获取父组件数据

watch: {
userInfo: {
handler(newValue, oldValue) {
this.ruleForm1.id = newValue.id;
this.ruleForm1.username = newValue.username;
this.ruleForm1.password = newValue.password;
this.ruleForm1.checkPass = newValue.password;
if (newValue.gender == "男") {
this.ruleForm1.gender = 1;
} else if(newValue.gender == "女") {
this.ruleForm1.gender = 2;
}
}
}
}

这里更新子组件的数据

//防止数据还没传输好就打开了表单
openedDialog(){
this.ruleForm = this.ruleForm1;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: