Estoy tratando de hacer i18n en mi proyecto Vue, luego ocurre un error.
Uncaught TypeError: Cannot read properties of undefined (reading 'use')Aquí está mi árbol de proyectos:
| -- Project | -- src | -- App.vue | -- main.js | -- store |-- index.js | -- lang | -- i18n.js | -- tw.json | -- en.jsoni18n.js:
import Vue from 'vue'; import VueI18n from 'vue-i18n'; Vue.use(VueI18n); import tw from './tw.json'; import en from './en.json'; const i18n = new VueI18n({ locale: localStorage.getItem('lang') || 'tw', messages: { tw, en } }); export default i18n;principal.js:
... import i18n from "./lang/i18n"; app.use(i18n);"vue": "^3.0.0", "vue-i18n": "^8.26.8", Nodo: v14.18.0
agregar js principales:
new Vue({ render: h => h(App), i18n }).$mount('#app');y
import i18n from "./lang/i18n";cambiar a
and * as i18n from "./lang/i18n";