问题
解决 1.两个表单的ref绑定的名称一样,把名称换一下,关闭的时候使用resetFields
页面代码:
新增时解耦:
close() {
this.$refs.userform.resetFields();
this.$refs.userformEdit.resetFields()
this.userform = {isDorm:0,isBreak:0,isGongjijin: 0};
this.dialogApply = false;
this.dialogInfo = false;
},
若首先编辑,会初始化值,再新增resetFields无效
编辑时解耦: 主要是把赋值写在nextTick里面,
this.$nextTick(()=> { this.userform = copy; this.oldBedNumId=copy.cwId; this.dormIsShow=false; this.noOne=false; if (this.userform.stafferType!=null&&this.userform.stafferType!=undefined){ this.userform.stafferType = this.userform.stafferType.toString(); } this.setSsqAndOrg(1); })