1.npm install babel-plugin-component -D 然后 .babelrc替换plugins 文件就在根目录下
2. 组件中英文及自定义中英文
import VueI18n from 'vue-i18n'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import ElementLocale from 'element-ui/lib/locale'
Vue.use(VueI18n)
Vue.use(DatePicker)
const messages = {
en: {
message: 'hello',
...enLocale
},
zh: {
message: '你好',
...zhLocale
}
}
// Create VueI18n instance with options
const i18n = new VueI18n({
locale: 'en', // set locale
messages, // set locale messages
})
ElementLocale.i18n((key, value) => i18n.t(key, value))
new Vue({
el: '#app',
i18n, //官网上的方法不行,写这里就可以了
router,
components: { App },
template: ''
})
3,。中英文切换 this.$i18n.locale ='cn'
标签:en,中英文,ElementUI,locale,i18n,import,VueI18n,加载
来源: https://www.cnblogs.com/dabiaogea/p/11224492.html