@@ -74,14 +74,19 @@ export default {
74
74
} ,
75
75
updateMenu ( ) {
76
76
const routes = this . $route . matched . concat ( )
77
-
78
- if ( routes . length >= 4 && this . $route . meta . hidden ) {
77
+ console . log ( 'updateMenu: routes -> ' , routes )
78
+ console . log ( 'this.$route' , this . $route )
79
+ console . log ( 'routes.length >= 3' , routes . length >= 3 , this . $route . meta )
80
+ const { hidden } = this . $route . meta
81
+ console . log ( 'hidden' , hidden )
82
+ if ( routes . length >= 3 && hidden ) {
79
83
routes . pop ( )
80
- this . selectedKeys = [ routes [ 2 ] . path ]
84
+ console . log ( 'updateMenu: routes -> ' , routes )
85
+ this . selectedKeys = [ routes [ routes . length - 1 ] . path ]
81
86
} else {
82
87
this . selectedKeys = [ routes . pop ( ) . path ]
83
88
}
84
-
89
+ console . log ( 'this.selectedKeys' , this . selectedKeys )
85
90
const openKeys = [ ]
86
91
if ( this . mode === 'inline' ) {
87
92
routes . forEach ( item => {
@@ -104,6 +109,16 @@ export default {
104
109
const tag = target && 'a' || 'router-link'
105
110
const props = { to : { name : menu . name } }
106
111
const attrs = { href : menu . path , target : menu . meta . target }
112
+
113
+ if ( menu . children && menu . hideChildrenInMenu ) {
114
+ // 把有子菜单的 并且 父菜单是要隐藏子菜单的
115
+ // 都给子菜单增加一个 hidden 属性
116
+ // 用来给刷新页面时, selectedKeys 做控制用
117
+ menu . children . forEach ( item => {
118
+ item . meta = Object . assign ( item . meta , { hidden : true } )
119
+ } )
120
+ }
121
+
107
122
return (
108
123
< Item { ...{ key : menu . path } } >
109
124
< tag { ...{ props, attrs } } >
0 commit comments