- 只需要在i18n配置里加上element-ui的国际化配置即可
//./lang/cn.js
export const message = {
home: '首页',
}
//./lang/en.js
export const message = {
home: 'Home',
}
//./i18n.js
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import locale from 'element-ui/lib/locale'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
Vue.use(VueI18n)
export const i18n = new VueI18n({
locale: 'cn',
messages: {
'cn': Object.assign(require('./langs/cn'), zhLocale),
'en': Object.assign(require('./langs/en'), enLocale)
}
})
locale.i18n((key, value) => i18n.t(key, value))
网友评论