useEffect(() => { form.clearErrors() if (state && state.data) { router.push('/') } // 后台错误 if (state && state.errorMessage) { // showErrorToast(t(state.errorMessage)) showErrorToast(state.errorMessage) } // 参数校验错误 if (state && state.error && Object.keys(state.error).length > 0) { const PHONE_ERROR_TEXT = t('LOGIN_PHONE_ERROR_TEXT') const LOGIN_PASSWORD_ERROR_TEXT = t('LOGIN_PASSWORD_ERROR_TEXT') for (const key in state.error) { if(key == formNames[0]){ state.error[key] = [PHONE_ERROR_TEXT] } if(key == formNames[1]){ state.error[key] = [LOGIN_PASSWORD_ERROR_TEXT] } } addServerErrors<LoginFormType>(state.error, form.setError) } }, [state, form])
addServerErrors 大致如下:
setError(key as keyof T, { type: 'server', message: errorMessage, })
标签:插件,error,form,intl,ERROR,state,key,TEXT From: https://www.cnblogs.com/xiaoyaoweb/p/18393469