Skip to content

Commit

Permalink
feat[Menu]: menu icon support el-icon
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Jun 15, 2020
1 parent 5c87772 commit e2fd7c7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/layout/components/Sidebar/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default {
const vnodes = []
if (icon) {
vnodes.push(<svg-icon icon-class={icon}/>)
if (icon.includes('el-icon')) {
vnodes.push(<i class={[icon, 'sub-el-icon']} />)
} else {
vnodes.push(<svg-icon icon-class={icon}/>)
}
}
if (title) {
Expand All @@ -27,3 +31,11 @@ export default {
}
}
</script>

<style scoped>
.sub-el-icon {
color: currentColor;
width: 1em;
height: 1em;
}
</style>
4 changes: 2 additions & 2 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Layout from '@/layout'
* meta : {
roles: ['admin','editor'] control the page roles (you can set multiple roles)
title: 'title' the name show in sidebar and breadcrumb (recommend set)
icon: 'svg-name' the icon show in the sidebar
icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
}
Expand Down Expand Up @@ -60,7 +60,7 @@ export const constantRoutes = [
component: Layout,
redirect: '/example/table',
name: 'Example',
meta: { title: 'Example', icon: 'example' },
meta: { title: 'Example', icon: 'el-icon-s-help' },
children: [
{
path: 'table',
Expand Down
17 changes: 17 additions & 0 deletions src/styles/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
margin-right: 16px;
}

.sub-el-icon {
margin-right: 12px;
margin-left: -2px;
}

.el-menu {
border: none;
height: 100%;
Expand Down Expand Up @@ -105,6 +110,10 @@
.svg-icon {
margin-left: 20px;
}

.sub-el-icon {
margin-left: 19px;
}
}
}

Expand All @@ -118,6 +127,10 @@
margin-left: 20px;
}

.sub-el-icon {
margin-left: 19px;
}

.el-submenu__icon-arrow {
display: none;
}
Expand Down Expand Up @@ -178,6 +191,10 @@
.svg-icon {
margin-right: 16px;
}
.sub-el-icon {
margin-right: 12px;
margin-left: -2px;
}
}

.nest-menu .el-submenu>.el-submenu__title,
Expand Down

0 comments on commit e2fd7c7

Please sign in to comment.