diff --git a/src/locales/index.ts b/src/locales/index.ts index 1e97ddf..1a03901 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -29,6 +29,10 @@ const i18n = createI18n({ * @param { string } localeKey 多语言的key,eg: "app.name" */ export const translate = (localeKey: string) => { + if (!localeKey) { + console.error(`[i18n] Function translate(), localeKey param is required`) + return '' + } const locale = getLocale() const message = messages[locale] if (Object.keys(message).includes(localeKey)) { diff --git a/src/pages/index/i18n.vue b/src/pages/index/i18n.vue index 3009474..fcd0275 100644 --- a/src/pages/index/i18n.vue +++ b/src/pages/index/i18n.vue @@ -1,5 +1,3 @@ - - { "style": { @@ -7,3 +5,11 @@ } } + + + + diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 431ac1b..8316b96 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -2,8 +2,8 @@ { style: { - // "navigationStyle": "custom", - navigationBarTitleText: '%app.name%', + navigationStyle: 'custom', + navigationBarTitleText: '首页', }, } @@ -12,7 +12,6 @@ class="bg-white h-full overflow-hidden pt-2 px-4" :style="{ marginTop: safeAreaInsets?.top + 'px' }" > - {{ $t('app.name') }} @@ -38,15 +37,8 @@