element - el-form多个表单需同时校验


element - el-form多个表单需同时校验

refs

this.$refs[('form1', 'form2', ...)].validate((valid, obj) => {})

Promise.all

// 当前弹框form校验
const p1 = new Promise((resolve, reject) => {
  this.$refs["form"].validate((valid) => {
    if (valid) resolve();
  });
});
// 数据源组件form校验
const p2 = new Promise((resolve, reject) => {
  this.$refs["ComTemplateDataSourceRef"].$refs["form"].validate(
    (valid) => {
      if (valid) resolve();
    }
  );
});
// 格式化组件form校验
const p3 = new Promise((resolve, reject) => {
  this.$refs["ComTemplateFormatRef"].$refs["form"].validate((valid) => {
    if (valid) resolve();
  });
});
 
Promise.all([p1, p2, p3]).then(async () => {
  // 做处理
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM