解决方案如下:
在main.js中导入相应的包,引入zhCn ,在使用时添加语言,代码如下:
import { createApp } from 'vue'
import pinia from '@/stores/index'
import App from './App.vue'
import router from './router'
import './assets/main.scss' //自己的样式尽可能的往下放
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 全局引入ElementPlus组件
import ElementPlus from 'element-plus'
//引入zhCn
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
app
.use(pinia)
.use(router)
.use(ElementPlus, { locale: zhCn })
.mount('#app')
转为中文样式如下: