解决v-for+多重表单验证
async emrForeSubmit() {
let list = []
for (let index = 0; index < this.$refs['firstTyperule'].length ; index++) {
list.push(
this.checkForm("firstTyperule",index),
)
}
for (let index = 0; index < this.$refs['secondTyperule'].length ; index++) {
list.push(
this.checkForm("secondTyperule",index),
)
}
for (let index = 0; index < this.$refs['thirdTyperule'].length ; index++) {
list.push(
this.checkForm("thirdTyperule",index),
)
}
for (let index = 0; index < this.$refs['forthTyperule'].length ; index++) {
list.push(
this.checkForm("forthTyperule",index),
)
}
Promise.all(list).then(() => {
console.log("通过")
})
.catch(() => {
console.log("未通过")
})
},
checkForm(formName,i) {
return new Promise((resolve, reject) => {
this.$refs[formName][i].validate(valid => {
if (valid) {
resolve()
} else reject()
})
})},