• Element---基于VUE的桌面端组件库


     ✨✨个人主页:沫洺的主页

    📚📚系列专栏: 📖 JavaWeb专栏📖 JavaSE专栏 📖 Java基础专栏📖vue3专栏 

                               📖MyBatis专栏📖Spring专栏📖SpringMVC专栏📖SpringBoot专栏

                               📖Docker专栏📖Reids专栏📖MQ专栏📖SpringCloud专栏     

    💖💖如果文章对你有所帮助请留下三连✨✨

    🌈Element

    🎉🎉Element:是饿了么公司前端开发团队提供的一套基于 Vue 的网站组件库,用于快速构建网页

    🎉🎉组件:组成网页的部件,例如 超链接、按钮、图片、表格等等~

    🎉🎉Element 官网:https://element.eleme.cn/#/zh-CNListener

    🎨Element 快速入门

    1. 📌引入Element 的css、js文件 和 Vue.js

    1. <script src="vue.js">script>
    2. <script src="element-ui/lib/index.js">script>
    3. <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">

    2. 📌创建Vue核心对象

    1. <script>
    2. new Vue({
    3. el:"#app"
    4. })
    5. script>

    3. 📌官网复制Element组件代码

    🎨Element 布局 

    Element 中有两种布局方式:

    1.📌Layout 布局:通过基础的 24 分栏,迅速简便地创建布局

    2.📌Container 布局容器:用于布局的容器组件,方便快速搭建页面的基本结构

    🔎Layout 布局

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. <script src="js/vue.js">script>
    7. <script src="element-ui/lib/index.js">script>
    8. <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
    9. <style>
    10. .el-row {
    11. margin-bottom: 20px;
    12. }
    13. .el-col {
    14. border-radius: 4px;
    15. }
    16. .bg-purple-dark {
    17. background: #99a9bf;
    18. }
    19. .bg-purple {
    20. background: #d3dce6;
    21. }
    22. .bg-purple-light {
    23. background: #e5e9f2;
    24. }
    25. .grid-content {
    26. border-radius: 4px;
    27. min-height: 36px;
    28. }
    29. .row-bg {
    30. padding: 10px 0;
    31. background-color: #f9fafc;
    32. }
    33. style>
    34. head>
    35. <body>
    36. <div id="app">
    37. <el-row>
    38. <el-col :span="24"><div class="grid-content bg-purple-dark">div>el-col>
    39. el-row>
    40. <el-row>
    41. <el-col :span="12"><div class="grid-content bg-purple">div>el-col>
    42. <el-col :span="12"><div class="grid-content bg-purple-light">div>el-col>
    43. el-row>
    44. <el-row>
    45. <el-col :span="8"><div class="grid-content bg-purple">div>el-col>
    46. <el-col :span="8"><div class="grid-content bg-purple-light">div>el-col>
    47. <el-col :span="8"><div class="grid-content bg-purple">div>el-col>
    48. el-row>
    49. <el-row>
    50. <el-col :span="6"><div class="grid-content bg-purple">div>el-col>
    51. <el-col :span="6"><div class="grid-content bg-purple-light">div>el-col>
    52. <el-col :span="6"><div class="grid-content bg-purple">div>el-col>
    53. <el-col :span="6"><div class="grid-content bg-purple-light">div>el-col>
    54. el-row>
    55. <el-row>
    56. <el-col :span="4"><div class="grid-content bg-purple">div>el-col>
    57. <el-col :span="4"><div class="grid-content bg-purple-light">div>el-col>
    58. <el-col :span="4"><div class="grid-content bg-purple">div>el-col>
    59. <el-col :span="4"><div class="grid-content bg-purple-light">div>el-col>
    60. <el-col :span="4"><div class="grid-content bg-purple">div>el-col>
    61. <el-col :span="4"><div class="grid-content bg-purple-light">div>el-col>
    62. el-row>
    63. div>
    64. <script>
    65. new Vue({
    66. el:"#app",
    67. data:{},
    68. methods:{},
    69. mounted:{
    70. }
    71. });
    72. script>
    73. body>
    74. html>

    🔎Container 布局容器

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. <script src="js/vue.js">script>
    7. <script src="element-ui/lib/index.js">script>
    8. <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
    9. <style>
    10. .el-header {
    11. background-color: #B3C0D1;
    12. color: #333;
    13. line-height: 60px;
    14. }
    15. .el-aside {
    16. color: #333;
    17. }
    18. style>
    19. head>
    20. <body>
    21. <div id="app">
    22. <el-container style="height: 500px; border: 1px solid #eee">
    23. <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    24. <el-menu :default-openeds="['1', '3']">
    25. <el-submenu index="1">
    26. <template slot="title"><i class="el-icon-message">i>导航一template>
    27. <el-menu-item-group>
    28. <template slot="title">分组一template>
    29. <el-menu-item index="1-1">选项1el-menu-item>
    30. <el-menu-item index="1-2">选项2el-menu-item>
    31. el-menu-item-group>
    32. <el-menu-item-group title="分组2">
    33. <el-menu-item index="1-3">选项3el-menu-item>
    34. el-menu-item-group>
    35. <el-submenu index="1-4">
    36. <template slot="title">选项4template>
    37. <el-menu-item index="1-4-1">选项4-1el-menu-item>
    38. el-submenu>
    39. el-submenu>
    40. <el-submenu index="2">
    41. <template slot="title"><i class="el-icon-menu">i>导航二template>
    42. <el-menu-item-group>
    43. <template slot="title">分组一template>
    44. <el-menu-item index="2-1">选项1el-menu-item>
    45. <el-menu-item index="2-2">选项2el-menu-item>
    46. el-menu-item-group>
    47. <el-menu-item-group title="分组2">
    48. <el-menu-item index="2-3">选项3el-menu-item>
    49. el-menu-item-group>
    50. <el-submenu index="2-4">
    51. <template slot="title">选项4template>
    52. <el-menu-item index="2-4-1">选项4-1el-menu-item>
    53. el-submenu>
    54. el-submenu>
    55. <el-submenu index="3">
    56. <template slot="title"><i class="el-icon-setting">i>导航三template>
    57. <el-menu-item-group>
    58. <template slot="title">分组一template>
    59. <el-menu-item index="3-1">选项1el-menu-item>
    60. <el-menu-item index="3-2">选项2el-menu-item>
    61. el-menu-item-group>
    62. <el-menu-item-group title="分组2">
    63. <el-menu-item index="3-3">选项3el-menu-item>
    64. el-menu-item-group>
    65. <el-submenu index="3-4">
    66. <template slot="title">选项4template>
    67. <el-menu-item index="3-4-1">选项4-1el-menu-item>
    68. el-submenu>
    69. el-submenu>
    70. el-menu>
    71. el-aside>
    72. <el-container>
    73. <el-header style="text-align: right; font-size: 12px">
    74. <el-dropdown>
    75. <i class="el-icon-setting" style="margin-right: 15px">i>
    76. <el-dropdown-menu slot="dropdown">
    77. <el-dropdown-item>查看el-dropdown-item>
    78. <el-dropdown-item>新增el-dropdown-item>
    79. <el-dropdown-item>删除el-dropdown-item>
    80. el-dropdown-menu>
    81. el-dropdown>
    82. <span>王小虎span>
    83. el-header>
    84. <el-main>
    85. <el-table :data="tableData">
    86. <el-table-column prop="date" label="日期" width="140">
    87. el-table-column>
    88. <el-table-column prop="name" label="姓名" width="120">
    89. el-table-column>
    90. <el-table-column prop="address" label="地址">
    91. el-table-column>
    92. el-table>
    93. el-main>
    94. el-container>
    95. el-container>
    96. div>
    97. <script>
    98. new Vue({
    99. el:"#app",
    100. data() {
    101. const item = {
    102. date: '2016-05-02',
    103. name: '王小虎',
    104. address: '上海市普陀区金沙江路 1518 弄'
    105. };
    106. return {
    107. tableData: Array(20).fill(item)
    108. }
    109. },
    110. methods:{},
    111. mounted:{
    112. }
    113. });
    114. script>
    115. body>
    116. html>

    🎨Element 组件

    🎈接下来使用element组件制作一个好看的表单

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. <script src="../js/vue.js">script>
    7. <script src="../element-ui/lib/index.js">script>
    8. <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
    9. <style>
    10. .el-table .warning-row {
    11. background: oldlace;
    12. }
    13. .el-table .success-row {
    14. background: #f0f9eb;
    15. }
    16. style>
    17. head>
    18. <body>
    19. <div id="app">
    20. <el-form :inline="true" :model="brand" class="demo-form-inline">
    21. <el-form-item label="当前状态">
    22. <el-select v-model="brand.status" placeholder="当前状态">
    23. <el-option label="启用" value="1">el-option>
    24. <el-option label="禁用" value="0">el-option>
    25. el-select>
    26. el-form-item>
    27. <el-form-item label="企业名称">
    28. <el-input v-model="brand.companyName" placeholder="企业名称">el-input>
    29. el-form-item>
    30. <el-form-item label="品牌名称">
    31. <el-input v-model="brand.brandName" placeholder="品牌名称">el-input>
    32. el-form-item>
    33. <el-form-item>
    34. <el-button type="primary" @click="onSubmit">查询el-button>
    35. el-form-item>
    36. el-form>
    37. <el-row>
    38. <el-button type="danger" plain>批量删除el-button>
    39. <el-button type="primary" plain @click="dialogVisible = true">新增el-button>
    40. el-row>
    41. <el-dialog
    42. title="编辑品牌"
    43. :visible.sync="dialogVisible"
    44. width="30%">
    45. <el-form ref="form" :model="brand" label-width="80px">
    46. <el-form-item label="品牌名称">
    47. <el-input v-model="brand.brandName">el-input>
    48. el-form-item>
    49. <el-form-item label="企业名称">
    50. <el-input v-model="brand.companyName">el-input>
    51. el-form-item>
    52. <el-form-item label="排序">
    53. <el-input v-model="brand.ordered">el-input>
    54. el-form-item>
    55. <el-form-item label="备注">
    56. <el-input type="textarea" v-model="brand.description">el-input>
    57. el-form-item>
    58. <el-form-item label="状态">
    59. <el-switch v-model="brand.status"
    60. active-value="1"
    61. inactive-value="0"
    62. >el-switch>
    63. el-form-item>
    64. <el-form-item>
    65. <el-button type="primary" @click="addBrand">提交el-button>
    66. <el-button @click="dialogVisible = false">取消el-button>
    67. el-form-item>
    68. el-form>
    69. el-dialog>
    70. <template>
    71. <el-table
    72. :data="tableData"
    73. style="width: 100%"
    74. :row-class-name="tableRowClassName"
    75. @selection-change="handleSelectionChange">
    76. <el-table-column
    77. type="selection"
    78. width="55">
    79. el-table-column>
    80. <el-table-column
    81. type="index"
    82. width="50">
    83. el-table-column>
    84. <el-table-column
    85. prop="brandName"
    86. label="品牌名称"
    87. align="center">
    88. el-table-column>
    89. <el-table-column
    90. prop="companyName"
    91. label="企业名称"
    92. align="center">
    93. el-table-column>
    94. <el-table-column
    95. prop="ordered"
    96. align="center"
    97. label="排序">
    98. el-table-column>
    99. <el-table-column
    100. prop="status"
    101. align="center"
    102. label="当前状态">
    103. el-table-column>
    104. <el-table-column
    105. align="center"
    106. label="操作">
    107. <el-button type="primary">修改el-button>
    108. <el-button type="danger">删除el-button>
    109. el-table-column>
    110. el-table>
    111. template>
    112. <el-pagination
    113. @size-change="handleSizeChange"
    114. @current-change="handleCurrentChange"
    115. :current-page="currentPage"
    116. :page-sizes="[5, 10, 15, 20]"
    117. :page-size="5"
    118. layout="total, sizes, prev, pager, next, jumper"
    119. :total="400">
    120. el-pagination>
    121. div>
    122. <script>
    123. new Vue({
    124. el:"#app",
    125. data() {
    126. return {
    127. //当前页码
    128. currentPage: 4,
    129. //添加数据对话框是否展示的标记
    130. dialogVisible: false,
    131. //品牌模型数据数据
    132. brand: {
    133. status: '',
    134. brandName: '',
    135. companyName: '',
    136. id:'',
    137. ordered:'',
    138. description:''
    139. },
    140. //复习框选中集合
    141. multipleSelection: [],
    142. //表格数据
    143. tableData: [{
    144. brandName: '华为',
    145. companyName: '华为科技有限公司',
    146. ordered: '100',
    147. status:'1'
    148. }, {
    149. brandName: '华为',
    150. companyName: '华为科技有限公司',
    151. ordered: '100',
    152. status:'1'
    153. }, {
    154. brandName: '华为',
    155. companyName: '华为科技有限公司',
    156. ordered: '100',
    157. status:'1'
    158. }, {
    159. brandName: '华为',
    160. companyName: '华为科技有限公司',
    161. ordered: '100',
    162. status:'1'
    163. }]
    164. }
    165. },
    166. methods: {
    167. //分页
    168. handleSizeChange(val) {
    169. console.log(`每页 ${val} 条`);
    170. },
    171. handleCurrentChange(val) {
    172. console.log(`当前页: ${val}`);
    173. },
    174. //表格
    175. tableRowClassName({row, rowIndex}) {
    176. if (rowIndex === 1) {
    177. return 'warning-row';
    178. } else if (rowIndex === 3) {
    179. return 'success-row';
    180. }
    181. return '';
    182. },
    183. //复选框选中后执行的方法
    184. handleSelectionChange(val) {
    185. this.multipleSelection = val;
    186. },
    187. //查询方法
    188. onSubmit() {
    189. console.log(this.brand);
    190. },
    191. //添加方法
    192. addBrand() {
    193. console.log(this.brand);
    194. }
    195. },
    196. mounted:{
    197. }
    198. });
    199. script>
    200. body>
    201. html>

    💦 说明

    🎁将element-ui包放到webapp下

    🎯网盘链接:https://pan.baidu.com/s/1NgM50O0X71Qm6LncPyReiw?pwd=wznb 
    提取码:wznb 

  • 相关阅读:
    MySQL数据库之用户管理
    bizlog通用操作日志组件(代码分析篇)
    【zabbix监控三】zabbix之部署代理服务器
    【无标题】
    Java实现桥接模式(设计模式 五)
    FreeSWITCH 1.10.10 简单图形化界面7-记录一次配置讯时网关的问题
    RK3568开发笔记(十):开发板buildroot固件移植开发的应用Demo,启动全屏显示
    基于Java毕业设计知识库系统源码+系统+mysql+lw文档+部署软件
    排列数字(DFS深度优先搜索)
    高考学计算机专业的小白指南,一些比较实用的软件,快速入手计算机
  • 原文地址:https://blog.csdn.net/HeyVIrBbox/article/details/126818847