elementplus国际化失败解决

按照官网教程配置,发现中文包不起作用。代码如下:

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/css/global.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//中文包
import zhCn from 'element-plus/es/locale/lang/zh-cn'

const app = createApp(App)
// 图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(store).use(router).use(ElementPlus).use(ElementPlus, {locale: zhCn,}).mount('#app')

经过几番尝试,发现问题出在这:

use(ElementPlus).use(ElementPlus, {locale: zhCn,})

引用覆盖,改为:

use(ElementPlus, {locale: zhCn,})
posted @ 2022-06-07 23:45  热心邻居老王  阅读(1699)  评论(0编辑  收藏  举报