elment 表单校验 编辑回显时有值还会触发校验&& 关闭新增弹框后重新打开还有标红校验


问题

 

 解决 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);
          })

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM