element-ui 中英文切换
import VueI18n from 'vue-i18n'import ElementUIfrom 'element-ui'import ElementLocale from 'element-ui/lib/locale'import enLocale from 'element-ui/lib/locale/lang/en'import zhLocale from 'element-...
·
import VueI18n from 'vue-i18n'
import ElementUI from 'element-ui'
import ElementLocale from 'element-ui/lib/locale'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import Cookies from 'js-cookie'
import lang from '@/common/lang' // 中英文翻译
Vue.use(ElementUI);
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: Cookies.get('language') || 'en', // 语言标识
messages: {
en: {
...lang.en,
...enLocale
},
zh: {
...lang.zh,
...zhLocale
}
}
});
Cookies.set('language',i18n.locale);
ElementLocale.i18n((key, value) => i18n.t(key, value))
原文:https://blog.csdn.net/github_37793365/article/details/83865237
更多推荐
已为社区贡献2条内容
所有评论(0)