在elementUI中触发el-form中的某一个校验

在form表单中 用ref绑定form

 如果想单独触发form表单中的某一项校验,可使用下面语句,其中括号里的是和el-form-item中的prop一致。

if (this.form.healthMatchRuleValueR) {

          this.$nextTick(()=>{

              this.$refs.form.validateField('healthMatchRuleValueR');

          })

   }

如果是涉及到编辑回填的校验,最好写在$nextTick()中,不然validateField会报错

猜你喜欢

转载自blog.csdn.net/m0_73533910/article/details/129750937