vue3引入elemen ui3

1、安装

npm install element-plus --save
 npm install @element-plus/icons-vue (icon库)


2、main.js
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

 

2、main.js

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)

app.use(router)
app.use(store)
app.use(ElementPlus)
app.mount('#app')

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}

3、英文转中文(app.vue)

<template>
<div style="height: 100%;">
<el-config-provider :locale="locale">
<router-view/>
</el-config-provider>
</div>
</template>
<script>
import { ElConfigProvider } from 'element-plus'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
export default {
components: {
ElConfigProvider
},
setup() {
return {
locale: zhCn
}
}
}
</script>

 



 
posted @ 2022-08-21 16:49  sosolucky  阅读(169)  评论(0编辑  收藏  举报