Procházet zdrojové kódy

feat[Menu]: menu icon support el-icon

花裤衩 před 5 roky
rodič
revize
e2fd7c7528

+ 13 - 1
src/layout/components/Sidebar/Item.vue

@@ -17,7 +17,11 @@ export default {
17 17
     const vnodes = []
18 18
 
19 19
     if (icon) {
20
-      vnodes.push(<svg-icon icon-class={icon}/>)
20
+      if (icon.includes('el-icon')) {
21
+        vnodes.push(<i class={[icon, 'sub-el-icon']} />)
22
+      } else {
23
+        vnodes.push(<svg-icon icon-class={icon}/>)
24
+      }
21 25
     }
22 26
 
23 27
     if (title) {
@@ -27,3 +31,11 @@ export default {
27 31
   }
28 32
 }
29 33
 </script>
34
+
35
+<style scoped>
36
+.sub-el-icon {
37
+  color: currentColor;
38
+  width: 1em;
39
+  height: 1em;
40
+}
41
+</style>

+ 2 - 2
src/router/index.js

@@ -19,7 +19,7 @@ import Layout from '@/layout'
19 19
  * meta : {
20 20
     roles: ['admin','editor']    control the page roles (you can set multiple roles)
21 21
     title: 'title'               the name show in sidebar and breadcrumb (recommend set)
22
-    icon: 'svg-name'             the icon show in the sidebar
22
+    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
23 23
     breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
24 24
     activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
25 25
   }
@@ -60,7 +60,7 @@ export const constantRoutes = [
60 60
     component: Layout,
61 61
     redirect: '/example/table',
62 62
     name: 'Example',
63
-    meta: { title: 'Example', icon: 'example' },
63
+    meta: { title: 'Example', icon: 'el-icon-s-help' },
64 64
     children: [
65 65
       {
66 66
         path: 'table',

+ 17 - 0
src/styles/sidebar.scss

@@ -57,6 +57,11 @@
57 57
       margin-right: 16px;
58 58
     }
59 59
 
60
+    .sub-el-icon {
61
+      margin-right: 12px;
62
+      margin-left: -2px;
63
+    }
64
+
60 65
     .el-menu {
61 66
       border: none;
62 67
       height: 100%;
@@ -105,6 +110,10 @@
105 110
         .svg-icon {
106 111
           margin-left: 20px;
107 112
         }
113
+
114
+        .sub-el-icon {
115
+          margin-left: 19px;
116
+        }
108 117
       }
109 118
     }
110 119
 
@@ -118,6 +127,10 @@
118 127
           margin-left: 20px;
119 128
         }
120 129
 
130
+        .sub-el-icon {
131
+          margin-left: 19px;
132
+        }
133
+
121 134
         .el-submenu__icon-arrow {
122 135
           display: none;
123 136
         }
@@ -178,6 +191,10 @@
178 191
     .svg-icon {
179 192
       margin-right: 16px;
180 193
     }
194
+    .sub-el-icon {
195
+      margin-right: 12px;
196
+      margin-left: -2px;
197
+    }
181 198
   }
182 199
 
183 200
   .nest-menu .el-submenu>.el-submenu__title,