Vuetify 使用 nuxt i18n 规则消息翻译

问题描述 投票:0回答:1
vue.js nuxt.js nuxt-i18n
1个回答
0
投票

您可以将翻译功能传递给规则定义:

const {t} = useI18n()

const nameValidationRules = ref([requiredRule(t), blankValidator(t)])
export const requiredRule = (t: any) => (value: any): string | boolean => !!value || t('required');
export const blankValidator = (t: any) => (value: string | null | undefined): string | boolean => !value || !!value?.trim() || t('not_blank');
© www.soinside.com 2019 - 2024. All rights reserved.