$t is not a function
See original GitHub issueHello,
sorry to post this here, i know it’s not the right place but 2 days and i can’t solve my issue.
When i use $t like this <h1>{{ $t('home.welcome') }}</h1>
in component or child component, i have Uncaught TypeError: _ctx.$t is not a function.
Can you explain to me, please ?
Thank you !
“vue”: “^3.0.0” “vue-i18n”: “^9.0.0”
import { createI18n } from 'vue-i18n'
import en from './locales/en.json'
import ja from './locales/ja.json'
export default createI18n({
legacy: false,
locale: "en",
messages: { en, ja }
})
import i18n from './i18n'
const app = createApp(AppVue)
app.use(i18n)
app.mount('#app')
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >Can't understand console error: 'Uncaught TypeError: t is not a ...
I am attempting to host a Ruby on Rails / React app in Heroku. Also of not, I am using the package google-maps-react ......
Read more >How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >JavaScript: Uncaught TypeError: n is not a function
Uncaught TypeError : 'n' is not a function: This is a standard JavaScript error when trying to call a function before it is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi it looks to me that that it could be the same issue I’ve encountered in the past, check if this solution solves it for you https://github.com/intlify/vue-i18n-next/issues/350#issuecomment-782007971
Sorry if I’m not explaining it better but I’m on mobile.
Thank you for your feedback!
Sorry for the Vue I18n docs wasted your time with their unfriendly documentation.
For me, your code looks like it’s using the Composition API. You need to specify
globalInjection
option tocreateI18n
function if you can use Implicitly the function prefixed with$
. 😃 https://vue-i18n.intlify.dev/guide/advanced/composition.html#implicit-with-injected-properties-and-functions