vue el-from校验成功但是 return不管用?-灵析社区

文文问问

async handleSubmit() { const flag = await this.$refs.form.validate().catch((e) => e) if (!flag) return this.loading = true try { await queryVipStandardEdit({ ...this.form, }) this.$message.success(this.$t('pls_operate_successful') + '!') this.close('success', true) } catch (error) { this.$message.error(error) } finally { this.loading = false } }, 校验生效了,但是if (!flag) return不管用,依然回走下面方法,哪里写错了

阅读量:297

点赞量:10

问AI
silennn
把 "catch" 去掉就行了 async handleSubmit() { await this.$refs.form.validate(); // ... }