vue中使用element-ui提交表单,同时验证多个form表单
多个表单同时校验目前公司的商家后台项目,在新增商品的时候,分成了多个模块,提交的表单的数据也是有多个对象组成,假设现在有baseInfoForm,skuInfoForm,freightForm,点击确定同时校验,验证通过则提交,一个不通过则不提交,使用promise.allasync saveInfo() {try {await Promise.all([this.$refs.baseInfoFo
·
多个表单同时校验
目前公司的商家后台项目,在新增商品的时候,分成了多个模块,提交的表单的数据也是有多个对象组成,假设现在有baseInfoForm,skuInfoForm,freightForm,点击确定同时校验,验证通过则提交,一个不通过则不提交,使用promise.all
async saveInfo() {
try {
await Promise.all([
this.$refs.baseInfoForm.validate(),
this.$refs.skuInfoForm.validate(),
this.$refs.freightForm.validate()
]);
} catch (error) {
return;
}
}
更多推荐
已为社区贡献2条内容
所有评论(0)