vue-i18n 如何与 vue 3 配合使用? [英] How make vue-i18n works with vue 3?
本文介绍了vue-i18n 如何与 vue 3 配合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是在 Vue 3 中安装了 vue-i18n
我遇到了错误;
I just install vue-i18n
with Vue 3 I got error;
我在 app.js
文件中的代码
import { createApp } from 'vue';
// ......
import en from './translate/en.json'
import ar from './translate/ar.json'
import ku from './translate/ku.json'
import { createI18n } from "vue-i18n";
const i18n = createI18n({
locale: 'ar',
messages: {
en,
ar,
ku,
}
})
const el = document.getElementById('app');
const app = createApp(App);
app.use(i18n);
app.mount(el);
错误:
WARNING in ./js/app.js 13:11-21
export 'createI18n' (imported as 'createI18n') was not found in 'vue-i18n' (possible exports: default)
webpack compiled with 1 warning
在控制台:
Uncaught TypeError: vue_i18n__WEBPACK_IMPORTED_MODULE_7__.createI18n is not a function
package.json
package.json
"dependencies": {
"tiny-emitter": "^2.1.0",
"vue-i18n": "^8.24.3"
}
推荐答案
您应该使用以下命令安装最新版本:
You should install the latest version using the following command :
npm uninstall vue-i18n
然后
npm i vue-i18n@next
因为vue-i18n@9.x
兼容 vue 3
because vue-i18n@9.x
is compatible with vue 3
这篇关于vue-i18n 如何与 vue 3 配合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文