There are instructions in the official documentation

Add Vue.component(component.name, component) if you only need to internationalize individual components in element-UI.

//main.js import Vue from 'vue' import App from './App.vue' import ElementUI from 'element-ui'; import { DatePicker, Pagination } from 'element-ui' import enLocale from 'element-ui/lib/locale/lang/en' import zhLocale from 'element-ui/lib/locale/lang/zh-CN' import VueI18n from 'vue-i18n'; import { messages } from '@components/common/i18n'; import 'element-ui/lib/theme-chalk/index.css'; // Default theme vue.config.productionTip = false vue.use (VueI18n); Const messages = {'zh': {demo:' Chinese ', // add the messages you need to internationalize here... zhLocale }, 'en':{ demo:'English', ... EnLocale,}} const i18n = new VueI18n({locale: 'en',// messages); Vue.component(datepicker. name, DatePicker) vue.component (Pagination. Name, DatePicker) Pagination) Vue.use(ElementUI, { size: 'small', // enLocale i18n:(key,value)=>i18n.t(key,value) }); new Vue({ i18n, render: h => h(App), }).$mount('#app')Copy the code

To store the language state in localStroage, click the button to switch languages: this.$i18n.locale=lang