This time I will bring you how to realize the international development of vue-i18n and element-ui in the vue project, and what are the things to note , the following is a practical case, let’s take a look.
By default you have built a vue project. In the vue projectInstall vue-i18n and element-ui plug-in
cnpm i vue-i18n --save-dev cnpm i element-ui --save-dev
import Vue from 'vue' import App from './App' import router from './router' // element-ui import Element from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' Vue.use(Element) // vuei18n import i18n from './i18n/i18n' Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', router, i18n, components: { App }, template: '<App/>' })
import Vue from 'vue' import locale from 'element-ui/lib/locale' import VueI18n from 'vue-i18n' import messages from './langs' Vue.use(VueI18n) const i18n = new VueI18n({ locale: localStorage.lang || 'cn', messages, }) locale.i18n((key, value) => i18n.t(key, value)) export default i18n
import en from './en'; import cn from './cn'; export default { en: en, cn: cn }
import enLocale from 'element-ui/lib/locale/lang/en' const en = { message: { 'mes': 'hello', }, ...enLocale } export default en;
import enLocale from 'element-ui/lib/locale/lang/zh-CN' const cn = { message: { 'mes': '你好', }, ...enLocale } export default cn;
The above is the detailed content of How to realize the international development of vue-i18n and element-ui in the vue project. For more information, please follow other related articles on the PHP Chinese website!