Browse Source

优化表单的错误处理

Michael Wang 3 years ago
parent
commit
1b3b619704
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/features/ChangePassword/ChangePassword.vue

+ 2 - 2
src/features/ChangePassword/ChangePassword.vue

@@ -44,11 +44,11 @@ const formRules: FormRules = {
   renewPassword: [password, { validator: equalToPswd, trigger: "input" }],
 };
 const inputChange = async () => {
-  await modelFormRef?.validate();
+  await modelFormRef?.validate().catch(() => 0);
 };
 
 const toSubmit = async () => {
-  await modelFormRef?.validate();
+  if (await modelFormRef?.validate().catch(() => true)) return;
 
   await changePwdApi(formModel.password, formModel.newPassword);
   message.success("修改成功!");