|
1 | 1 | <template>
|
2 |
| - <div v-if="!item.hidden&&item.children" class="menu-wrapper"> |
| 2 | + <div v-if="!item.hidden" class="menu-wrapper"> |
3 | 3 |
|
4 | 4 | <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
|
5 | 5 | <app-link :to="resolvePath(onlyOneChild.path)">
|
6 | 6 | <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
|
7 |
| - <item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon||item.meta.icon" :title="generateTitle(onlyOneChild.meta.title)" /> |
| 7 | + <item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="generateTitle(onlyOneChild.meta.title)" /> |
8 | 8 | </el-menu-item>
|
9 | 9 | </app-link>
|
10 | 10 | </template>
|
11 | 11 |
|
12 | 12 | <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)">
|
13 | 13 | <template slot="title">
|
14 |
| - <item v-if="item.meta" :icon="item.meta.icon" :title="generateTitle(item.meta.title)" /> |
15 |
| - </template> |
16 |
| - |
17 |
| - <template v-for="child in item.children"> |
18 |
| - <template v-if="!child.hidden"> |
19 |
| - <sidebar-item |
20 |
| - v-if="child.children&&child.children.length>0" |
21 |
| - :is-nest="true" |
22 |
| - :item="child" |
23 |
| - :key="child.path" |
24 |
| - :base-path="resolvePath(child.path)" |
25 |
| - class="nest-menu" /> |
26 |
| - |
27 |
| - <app-link v-else :to="resolvePath(child.path)" :key="child.name"> |
28 |
| - <el-menu-item :index="resolvePath(child.path)"> |
29 |
| - <item v-if="child.meta" :icon="child.meta.icon" :title="generateTitle(child.meta.title)" /> |
30 |
| - </el-menu-item> |
31 |
| - </app-link> |
32 |
| - </template> |
| 14 | + <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="generateTitle(item.meta.title)" /> |
33 | 15 | </template>
|
| 16 | + <sidebar-item |
| 17 | + v-for="child in item.children" |
| 18 | + :is-nest="true" |
| 19 | + :item="child" |
| 20 | + :key="child.path" |
| 21 | + :base-path="resolvePath(child.path)" |
| 22 | + class="nest-menu" /> |
34 | 23 | </el-submenu>
|
35 | 24 |
|
36 | 25 | </div>
|
@@ -70,7 +59,7 @@ export default {
|
70 | 59 | return {}
|
71 | 60 | },
|
72 | 61 | methods: {
|
73 |
| - hasOneShowingChild(children, parent) { |
| 62 | + hasOneShowingChild(children = [], parent) { |
74 | 63 | const showingChildren = children.filter(item => {
|
75 | 64 | if (item.hidden) {
|
76 | 65 | return false
|
|
0 commit comments