Skip to content

Commit

Permalink
增加捕获表单验证提示信息
Browse files Browse the repository at this point in the history
  • Loading branch information
think-gem committed Nov 7, 2024
1 parent ab8436d commit f324661
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/views/sys/login/RegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@
import { StrengthMeter } from '/@/components/StrengthMeter';
import { CountdownInput } from '/@/components/CountDown';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin';
const FormItem = Form.Item;
const InputPassword = Input.Password;
const { t } = useI18n();
const { showMessage } = useMessage();
const { handleBackLogin, getLoginState } = useLoginState();
const formRef = ref();
Expand All @@ -99,8 +101,15 @@
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.REGISTER);
async function handleRegister() {
const data = await validForm();
if (!data) return;
console.log(data);
try {
const data = await validForm();
if (!data) return;
showMessage('提交数据:' + JSON.stringify(data));
} catch (error: any) {
if (error && error.errorFields) {
showMessage(error.message || t('common.validateError'));
}
console.log('error', error);
}
}
</script>

0 comments on commit f324661

Please sign in to comment.