問題
解決 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); })