element多个表单同时验证

handleSave() {
  let list = [];
  list.push(
    this.checkForm("oneRef"),
    this.checkForm("twoRef"),
    this.checkForm("threeRef"),
    this.checkForm("fourRef"),
    this.checkForm("fiveRef"),
    this.checkForm("sixRef"),
  );
  Promise.all(list)
  .then(() => {
    console.log("表单验证通过");
  })
  .catch(() => {
    console.log("表单验证通过");
  });
},
//多个表单同时验证
checkForm(formName) {
  return new Promise((resolve, reject) => {
    this.$refs[formName].validate(valid => {
      if (valid) {
        resolve();
      } else reject();
    });
  });
},

你可能感兴趣的:(项目问题小记,javascript,开发语言,ecmascript)