vue+element之多表单验证

方法一:利用promise
        var p1=new Promise(function(resolve, reject) {
        
            this.$refs[form1].validate((valid) => {
                if(valid){
                    resolve();
                }
            })
        });
        
        var p2=new Promise(function(resolve, reject) {
             this.$refs[form2].validate((valid) => {
              if(valid){
                resolve();
              }
            })
        });
        
        
        
        Promise.all([p2,p1]).then(function(){
            alert("验证通过了");
        });
方法2:开关的方式
        this.$refs[a].validate((valid) => {
         
                if (valid) {
                  this.titleFormValid = true
                }
              })
               this.$refs[b].validate((valid) => {
                    if(valid){
                       this.customFormValid = true
                    } 
                })
               if (this.titleFormValid && this.customFormValid) {
                 alert("保存成功")
               }
              }
原文地址:https://www.cnblogs.com/raind/p/9651175.html