element 同时校验循环遍历的多个表单

<div v-for="(arg, index) in list" :key="index">
 <el-form ref="`form-${index + 1}`" :model="arg"></el-form>
</div>
   let count = 0
   list.forEach((v, i) => {
    this.$refs[`form-${i+1}`].validate(valid => {
     if (valid) {
      count++
     }
    })
   })
   if (count === list.length) {
    alert('校验通过')
   }

 

posted @ 2022-08-18 08:56  氧化成风  阅读(390)  评论(0编辑  收藏  举报