Vue Need to install with `app.use` function ue3+i18n 國際化處理

Uncaught SyntaxError: Need to install with `app.use` function (at message-compiler.esm-bundler.js:54:19)

at createCompileError (message-compiler.esm-bundler.js:54:19)
at createI18nError (vue-i18n.esm-bundler.js:100:12)
at useI18n (vue-i18n.esm-bundler.js:2219:15)
at setup (App.vue:29:18)
at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
at setupStatefulComponent (runtime-core.esm-bundler.js:7204:29)
at setupComponent (runtime-core.esm-bundler.js:7159:11)
at mountComponent (runtime-core.esm-bundler.js:5508:13)
at processComponent (runtime-core.esm-bundler.js:5483:17)
at patch (runtime-core.esm-bundler.js:5085:21)

 

意思說createI18n 未創建,就使用了useI18n 方法,造成報錯。

看到這個大哥vue3+i18n 國際化處理,後面才知道原來寫的順序錯了,因爲我先做了

app.mount('#app')

 

在做了

app.use(i18n)

 

只需要修改成

app.use(i18n)
app.mount('#app')

 

後續又報錯Not available in legacy mode 

只需要在createI18n的方法裏面加上legacy: false,

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章