File tree 1 file changed +17
-6
lines changed
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div v-if =" !item.hidden&&item.children" class =" menu-wrapper" >
3
3
4
- <router-link v-if =" hasOneShowingChildren (item.children) && !item .children[0].children && !item.alwaysShow" :to =" resolvePath(item.children[0] .path)" >
5
- <el-menu-item :index =" resolvePath(item.children[0] .path)" :class =" {'submenu-title-noDropdown':!isNest}" >
6
- <svg-icon v-if =" item.children[0]. meta&&item.children[0]. meta.icon" :icon-class =" item.children[0] .meta.icon" ></svg-icon >
7
- <span v-if =" item.children[0]. meta&&item.children[0]. meta.title" slot =" title" >{{generateTitle(item.children[0] .meta.title)}}</span >
4
+ <router-link v-if =" hasOneShowingChild (item.children) && !onlyOneChild .children&& !item.alwaysShow" :to =" resolvePath(onlyOneChild .path)" >
5
+ <el-menu-item :index =" resolvePath(onlyOneChild .path)" :class =" {'submenu-title-noDropdown':!isNest}" >
6
+ <svg-icon v-if =" onlyOneChild. meta&&onlyOneChild. meta.icon" :icon-class =" onlyOneChild .meta.icon" ></svg-icon >
7
+ <span v-if =" onlyOneChild. meta&&onlyOneChild. meta.title" slot =" title" >{{generateTitle(onlyOneChild .meta.title)}}</span >
8
8
</el-menu-item >
9
9
</router-link >
10
10
@@ -50,10 +50,21 @@ export default {
50
50
default: ' '
51
51
}
52
52
},
53
+ data () {
54
+ return {
55
+ onlyOneChild: null
56
+ }
57
+ },
53
58
methods: {
54
- hasOneShowingChildren (children ) {
59
+ hasOneShowingChild (children ) {
55
60
const showingChildren = children .filter (item => {
56
- return ! item .hidden
61
+ if (item .hidden ) {
62
+ return false
63
+ } else {
64
+ // temp set(will be used if only has one showing child )
65
+ this .onlyOneChild = item
66
+ return true
67
+ }
57
68
})
58
69
if (showingChildren .length === 1 ) {
59
70
return true
You can’t perform that action at this time.
0 commit comments