Skip to content

Commit fc68f56

Browse files
authored
feat[Menu]: menu icon support el-icon(PanJiaChen#3048)
1 parent d3bd933 commit fc68f56

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/layout/components/Sidebar/Item.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export default {
1717
const vnodes = []
1818
1919
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+
}
2125
}
2226
2327
if (title) {
@@ -27,3 +31,11 @@ export default {
2731
}
2832
}
2933
</script>
34+
35+
<style scoped>
36+
.sub-el-icon {
37+
color: currentColor;
38+
width: 1em;
39+
height: 1em;
40+
}
41+
</style>

src/router/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import nestedRouter from './modules/nested'
2525
* meta : {
2626
roles: ['admin','editor'] control the page roles (you can set multiple roles)
2727
title: 'title' the name show in sidebar and breadcrumb (recommend set)
28-
icon: 'svg-name' the icon show in the sidebar
28+
icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
2929
noCache: true if set true, the page will no be cached(default is false)
3030
affix: true if set true, the tag will affix in the tags-view
3131
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
@@ -197,14 +197,14 @@ export const asyncRoutes = [
197197
name: 'Example',
198198
meta: {
199199
title: 'Example',
200-
icon: 'example'
200+
icon: 'el-icon-s-help'
201201
},
202202
children: [
203203
{
204204
path: 'create',
205205
component: () => import('@/views/example/create'),
206206
name: 'CreateArticle',
207-
meta: { title: 'Create Article', icon: 'edit' }
207+
meta: { title: 'Create Article', icon: 'el-icon-s-help' }
208208
},
209209
{
210210
path: 'edit/:id(\\d+)',

src/styles/sidebar.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
margin-right: 16px;
5858
}
5959

60+
.sub-el-icon {
61+
margin-right: 12px;
62+
margin-left: -2px;
63+
}
64+
6065
.el-menu {
6166
border: none;
6267
height: 100%;
@@ -105,6 +110,10 @@
105110
.svg-icon {
106111
margin-left: 20px;
107112
}
113+
114+
.sub-el-icon {
115+
margin-left: 19px;
116+
}
108117
}
109118
}
110119

@@ -118,6 +127,10 @@
118127
margin-left: 20px;
119128
}
120129

130+
.sub-el-icon {
131+
margin-left: 19px;
132+
}
133+
121134
.el-submenu__icon-arrow {
122135
display: none;
123136
}
@@ -178,6 +191,10 @@
178191
.svg-icon {
179192
margin-right: 16px;
180193
}
194+
.sub-el-icon {
195+
margin-right: 12px;
196+
margin-left: -2px;
197+
}
181198
}
182199

183200
.nest-menu .el-submenu>.el-submenu__title,

0 commit comments

Comments
 (0)