nuxt3在setup外部引用i18n的t函数的正确方法 目的是直接封装一个$t函数,可以直接在script中使用。 如果直接这样写,会报错 “Must be called at the top of a `setup`” function $t(args){ const {t}=useI18n() t(args) } 所以可以这样写: function $t(args1: any,args2?:any, args3?:any){const...
EN我有一个使用vue-i18n的typescript Vue.js应用程序,我想把它移植到Nuxt.js上。在Vue.js应用程序中...
I also disabled all plugins and deleted the IDE configuration to make sure the problem is not with third-party plugins or settings IgorKha commented on Dec 22, 2024 IgorKha on Dec 22, 2024 Author I found the root of the problem it's related to this problem, so please forgive me for...
I'm currently using vue-i18n as a plugin in a Nuxt 3 project but I would like to switch to @nuxtjs/i18n as soon as possible. I tried to installed the alpha version but as soon as I declare the module in nuxt.config.js, I've got an error when I do npm run dev. Cannot find ...
<LocLink to="/">{{ $t('nav_home') }}</LocLink> 6、语言切换组件 代码 <!-- components/LangSwitcher.vue --> // Used for type casting // Used for type casting import type { LocaleObject } from "@nuxtjs/i18n/dist/runtime/composables"; // Get active locale and supported locales...
In your pages/index.vue import{errorStatus}from"@shuami-dev/nuxt-error-status"import{useI18n}from"vue-i18n"const{ t }=useI18n()consterror=ref<Error|string|null|undefined>(null)//Custom error handler (optional)constoptErrorHandler=(error:Error|string|null|undefined)=>{if((typeoferror==="...
@nuxtjs/i18n Official support is in beta, check the docs. @nuxtjs/proxy This feature is coming to nitro route rules. You can track it here: https://github.com/unjs/nitro/issues/113. In the meantime, you can use the nuxt-alt/proxy module. @nuxtjs/eslint-module The Nuxt 2 version...
只能在 setup 函数中使用,不能在中间件里面用,后面无意中发现 nuxtApp 中有一个 $i18n 的属性,而 useNuxtApp() 是可以在中间件中使用的,这不就解决了吗?结果 Not found 'title' key in 'en-US' locale messages. 这en-US 是什么东西?locale 明明设置的 cn,然后我打印了一下 useI18n() 跟 nuxtApp....
给定以下组件: 给定以下组件: <template> <WglResultList :show-sorting="true" :page-title="pageTitle" :sort-label="t('sortLabel')" :sort-title="t('sortTitle'
│ at async setup (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxtjs+i18n@8.0.0-beta.10_vue@3.2.47/node_modules/@nuxtjs/i18n/dist/module.mjs:964:5) │ at async normalizedModule (/D:/GitRepo/serverless/frontend-monorepo/node_modules/.pnpm/@nuxt+kit@3.4.3/node_modules...