Element-Plus的使用

本文最后更新于:2023年7月28日 凌晨

安装

1
pnpm i element-plus --save

挂载

1
2
3
4
5
6
7
8
9
10
// main.ts[main.js]
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'

const app = createApp(App)

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

icon库

1
pnpm install @element-plus/icons-vue

此时可按需引用

1
2
3
<script setup>
import { Key } from '@element-plus/icons-vue'
</script>

全局注册

1
2
3
4
5
6
7
import * as icons from '@element-plus/icons-vue'

const app = createApp(App)

Object.keys(icons).forEach(key => {
app.component(key, icons[key])
})

可在组件内如下使用

1
2
3
4
5
<template>
<el-icon>
<key />
</el-icon>
</template>

Element-Plus的使用
https://qingshaner.com/Element-Plus的使用/
作者
清山
发布于
2022年3月6日
许可协议