vue中引入vue-i18n方式见链接:https://www.cnblogs.com/vickylinj/p/9537717.html
vue 中文言分成两个文件分别管理:
en.js:
1 const en = { 2 message: { 3 'hello': 'hello, world', 4 } 5 } 6 7 export default en
zh.js:
const zh = { message: { 'hello': '你好,世界', } } export default zh
main.js中引入element-ui国际化文件:
1 import Vue from 'vue' 2 import localeElement from 'element-ui/lib/locale' 3 import enLocale from 'element-ui/lib/locale/lang/en' 4 import zhLocale from 'element-ui/lib/locale/lang/zh-CN' 5 import en from '/en.js' 6 import zh from 'zh.js' 7 import VueI18n from 'vue-i18n' 8 9 Vue.use(VueI18n) 10 const i18n = new VueI18n({ 11 locale: localStorage.lang || 'cn', 12 messages:{ 13 'en':{...en,...enLocale}, 14 'zh':{...zh,...zhLocale} 15 } 16 }) 17 localeElement .i18n((key, value) => i18n.t(key, value)) //重点:为了实现element插件的多语言切换