✨✨个人主页:沫洺的主页
📚📚系列专栏: 📖 JavaWeb专栏📖 JavaSE专栏 📖 Java基础专栏📖vue3专栏
📖MyBatis专栏📖Spring专栏📖SpringMVC专栏📖SpringBoot专栏
📖Docker专栏📖Reids专栏📖MQ专栏📖SpringCloud专栏
💖💖如果文章对你有所帮助请留下三连✨✨
📅Element Plus
🎫Element Plus官网:Element Plus
🎫Element-UI和Element-Plus的区别
- 📌Element-UI: 基于vue2版本,对应Element2:基本不支持手机版
- 📌Element-Plus: 基于vue3版,对应Element3:组件布局考虑了手机版展示
🎃安装
🎈 npm install element-plus --save
🎃全局安装图标
🎈 npm install @element-plus/icons-vue
🎃main.ts 使用 ElementPlus插件
import { createApp } from 'vue' import App from './App.vue' //引入路由文件 import router from './router/index' //导入store import store from './store/index' //使用ElementPlus插件 import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import * as ElementPlusIconsVue from '@element-plus/icons-vue' //使用路由组件 const app=createApp(App) //全局导入Element图标 for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } //使用ElementPlus插件 app.use(ElementPlus) app.use(router) //使用store app.use(store) app.mount('#app')
🎃Element Plus入门使用
分别将标签template和script中的代码复制到自己的.vue文件中
<template> 商品列表子页 <el-row class="mb-4"> <el-button>Default</el-button> <el-button type="primary">Primary</el-button> <el-button type="success">Success</el-button> <el-button type="info">Info</el-button> <el-button type="warning">Warning</el-button> <el-button type="danger">Danger</el-button> </el-row> <el-row class="mb-4"> <el-button plain>Plain</el-button> <el-button type="primary" plain>Primary</el-button> <el-button type="success" plain>Success</el-button> <el-button type="info" plain>Info</el-button> <el-button type="warning" plain>Warning</el-button> <el-button type="danger" plain>Danger</el-button> </el-row> <el-row class="mb-4"> <el-button round>Round</el-button> <el-button type="primary" round>Primary</el-button> <el-button type="success" round>Success</el-button> <el-button type="info" round>Info</el-button> <el-button type="warning" round>Warning</el-button> <el-button type="danger" round>Danger</el-button> </el-row> <el-row> <el-button :icon="Search" circle /> <el-button type="primary" :icon="Edit" circle /> <el-button type="success" :icon="Check" circle /> <el-button type="info" :icon="Message" circle /> <el-button type="warning" :icon="Star" circle /> <el-button type="danger" :icon="Delete" circle /> </el-row> </template> <script setup lang="ts"> import { Check, Delete, Edit, Message, Search, Star, } from '@element-plus/icons-vue' </script>
Table表格
<template> <el-table :data="tableData" style="width: 100%" > <el-table-column prop="date" label="Date" width="180" /> <el-table-column prop="name" label="Name" width="180" /> <el-table-column prop="address" label="Address" /> </el-table> </template> <script setup lang="ts"> const tableData = [ { date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles', }, { date: '2016-05-02', name: 'Tom', address: 'No. 189, Grove St, Los Angeles', }, { date: '2016-05-04', name: 'Tom', address: 'No. 189, Grove St, Los Angeles', }, { date: '2016-05-01', name: 'Tom', address: 'No. 189, Grove St, Los Angeles', }, ] </script>