Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 5396d00

Browse files
committed
fix(Aside): adjust default icon strategy
- Only root route has a default icon
1 parent 1b23c58 commit 5396d00

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/layout/Material/Aside/Item.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
<el-menu-item
1212
:index="resolvePath(route.path)"
1313
>
14+
<!-- 仅仅在根路由的情况下存在默认图标 `el-icon-news` -->
15+
<!-- Only root routes has a default icon. -->
1416
<item-title
15-
:icon="route.meta.icon"
17+
:icon="route.meta.icon
18+
|| (isRootPath(route.path) ? 'el-icon-news' : '')"
1619
:title="route.meta.title"
1720
/>
1821
</el-menu-item>
@@ -78,6 +81,9 @@ export default {
7881
methods: {
7982
resolvePath (targetPath) {
8083
return path.resolve(this.basicRoute, targetPath)
84+
},
85+
isRootPath (path) {
86+
return /^\//.test(path)
8187
}
8288
},
8389

src/layout/Material/Aside/ItemTitle.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ export default {
44
props: {
55
icon: {
66
type: String,
7-
default: 'el-icon-news'
7+
// 在父级组件中判断为根路由是才存在默认图标
8+
// Only root routes has a default icon
9+
default: ''
810
},
911
title: {
1012
type: String,

0 commit comments

Comments
 (0)