vue中使用elementui做表单提交时,同时验证多个form&&获取子组件的组件

多个表单同时验证
项目中遇到这样的多个表单同时提交,内容太多,分成两个form表单,一个是basicForm,一个是advanceForm,点击确定按钮时同时验证,验证通过提交表单,有一个不通过则不提交,代码是这样写的

    addData() {
      try {
        Promise.all([
          this.$refs.refName.$refs.ruleForm1.elForm.validate(),
          this.$refs.refName.$refs.ruleForm2.elForm.validate()
        ]).then((res) => {
          console.log('效验通过')
        })
      } catch (error) {
        return
      }
    },

 

使用的是promisea.all

 

 

获取子组件的组件

his.$refs.refName.$refs.ruleForm1.elForm

 

posted @ 2020-12-08 15:03  laowang666888  阅读(1722)  评论(0编辑  收藏  举报