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);
          })
复制代码

 

posted @   Li_ll  Views(1235)  Comments(0Edit  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示