其他分享
首页 > 其他分享> > elementplus国际化失败解决

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,})

标签:use,国际化,locale,app,elementplus,失败,plus,import,ElementPlus
来源: https://www.cnblogs.com/roud/p/16353920.html