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,

 

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