Element Plus UI 安装
安装
1 2 3 4 5 6 7 8 9 10 | # 选择一个你喜欢的包管理器 # NPM $ npm install element-plus --save # Yarn $ yarn add element-plus # pnpm $ pnpm install element-plus |
完整引入
如果你对打包后的文件大小不是很在乎,那么使用完整导入会更方便。
1 2 3 4 5 6 7 8 9 10 | // main.ts 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' ) |
olar 支持
如果您使用 Volar,请在 tsconfig.json
中通过 compilerOptions.type
指定全局组件类型。
1 2 3 4 5 6 7 | // tsconfig.json { "compilerOptions" : { // ... "types" : [ "element-plus/global" ] } } |
Icon 图标
1 2 3 4 5 6 7 8 | # 选择一个你喜欢的包管理器 # NPM $ npm install @element-plus/icons-vue # Yarn $ yarn add @element-plus/icons-vue # pnpm $ pnpm install @element-plus/icons-vue |
注册所有图标
您需要从 @element-plus/icons-vue
中导入所有图标并进行全局注册。
1 2 3 4 5 6 7 8 9 | // main.ts // 如果您正在使用CDN引入,请删除下面一行。 import * as ElementPlusIconsVue from '@element-plus/icons-vue' const app = createApp(App) for ( const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!