Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianzhuanghu
ant-design-pro-vue
Commits
13424f55
Commit
13424f55
authored
Sep 08, 2018
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed menu that all the other menus gets collapsed to keep the entire menu compact.
parent
b25c20c8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
SiderMenu.vue
src/components/menu/SiderMenu.vue
+1
-1
index.js
src/components/menu/index.js
+23
-17
No files found.
src/components/menu/SiderMenu.vue
View file @
13424f55
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
SMenu
from
'./index'
import
SMenu
from
'./index'
export
default
{
export
default
{
name
:
"SiderMenu"
,
name
:
"SiderMenu"
,
components
:
{
ALayoutSider
,
SMenu
},
components
:
{
ALayoutSider
,
SMenu
},
props
:
{
props
:
{
collapsible
:
{
collapsible
:
{
type
:
Boolean
,
type
:
Boolean
,
...
...
src/components/menu/index.js
View file @
13424f55
...
@@ -28,12 +28,18 @@ export default {
...
@@ -28,12 +28,18 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
rootSubmenuKeys
:
[],
openKeys
:
[],
openKeys
:
[],
selectedKeys
:
[],
selectedKeys
:
[],
cachedOpenKeys
:
[]
cachedOpenKeys
:
[]
}
}
},
},
computed
:
{
rootSubmenuKeys
:
(
vm
)
=>
{
let
keys
=
[]
vm
.
menu
.
forEach
(
item
=>
keys
.
push
(
item
.
path
))
return
keys
}
},
created
()
{
created
()
{
this
.
updateMenu
()
this
.
updateMenu
()
},
},
...
@@ -53,39 +59,39 @@ export default {
...
@@ -53,39 +59,39 @@ export default {
methods
:
{
methods
:
{
renderIcon
:
function
(
h
,
icon
)
{
renderIcon
:
function
(
h
,
icon
)
{
return
icon
===
'none'
||
icon
===
undefined
?
null
return
icon
===
'none'
||
icon
===
undefined
?
null
:
h
(
Icon
,
{
props
:
{
type
:
icon
!==
undefined
?
icon
:
''
}
})
:
h
(
Icon
,
{
props
:
{
type
:
icon
!==
undefined
?
icon
:
''
}
})
},
},
renderMenuItem
:
function
(
h
,
menu
,
pIndex
,
index
)
{
renderMenuItem
:
function
(
h
,
menu
,
pIndex
,
index
)
{
return
h
(
Item
,
{
key
:
menu
.
path
?
menu
.
path
:
'item_'
+
pIndex
+
'_'
+
index
},
return
h
(
Item
,
{
key
:
menu
.
path
?
menu
.
path
:
'item_'
+
pIndex
+
'_'
+
index
},
[
[
h
(
h
(
'router-link'
,
'router-link'
,
{
attrs
:
{
to
:
{
name
:
menu
.
name
}
}
},
{
attrs
:
{
to
:
{
name
:
menu
.
name
}
}
},
[
[
this
.
renderIcon
(
h
,
menu
.
meta
.
icon
),
this
.
renderIcon
(
h
,
menu
.
meta
.
icon
),
h
(
'span'
,
[
menu
.
meta
.
title
])
h
(
'span'
,
[
menu
.
meta
.
title
])
]
]
)
)
]
]
)
)
},
},
renderSubMenu
:
function
(
h
,
menu
,
pIndex
,
index
)
{
renderSubMenu
:
function
(
h
,
menu
,
pIndex
,
index
)
{
var
this2_
=
this
const
this2_
=
this
;
var
subItem
=
[
h
(
'span'
,
let
subItem
=
[
h
(
'span'
,
{
slot
:
'title'
},
{
slot
:
'title'
},
[
[
this
.
renderIcon
(
h
,
menu
.
meta
.
icon
),
this
.
renderIcon
(
h
,
menu
.
meta
.
icon
),
h
(
'span'
,
[
menu
.
meta
.
title
])
h
(
'span'
,
[
menu
.
meta
.
title
])
]
]
)
]
)
]
var
itemArr
=
[]
let
itemArr
=
[]
var
pIndex_
=
pIndex
+
'_'
+
index
let
pIndex_
=
pIndex
+
'_'
+
index
menu
.
children
.
forEach
(
function
(
item
,
i
)
{
menu
.
children
.
forEach
(
function
(
item
,
i
)
{
itemArr
.
push
(
this2_
.
renderItem
(
h
,
item
,
pIndex_
,
i
))
itemArr
.
push
(
this2_
.
renderItem
(
h
,
item
,
pIndex_
,
i
))
})
})
return
h
(
return
h
(
SubMenu
,
SubMenu
,
{
key
:
menu
.
path
?
menu
.
path
:
'submenu_'
+
pIndex
+
'_'
+
index
},
{
key
:
menu
.
path
?
menu
.
path
:
'submenu_'
+
pIndex
+
'_'
+
index
},
subItem
.
concat
(
itemArr
)
subItem
.
concat
(
itemArr
)
)
)
},
},
...
@@ -95,8 +101,8 @@ export default {
...
@@ -95,8 +101,8 @@ export default {
}
}
},
},
renderMenu
:
function
(
h
,
menuTree
)
{
renderMenu
:
function
(
h
,
menuTree
)
{
var
this2_
=
this
const
this2_
=
this
var
menuArr
=
[]
let
menuArr
=
[]
menuTree
.
forEach
(
function
(
menu
,
i
)
{
menuTree
.
forEach
(
function
(
menu
,
i
)
{
if
(
!
menu
.
hidden
)
{
if
(
!
menu
.
hidden
)
{
menuArr
.
push
(
this2_
.
renderItem
(
h
,
menu
,
'0'
,
i
))
menuArr
.
push
(
this2_
.
renderItem
(
h
,
menu
,
'0'
,
i
))
...
@@ -109,12 +115,12 @@ export default {
...
@@ -109,12 +115,12 @@ export default {
if
(
this
.
rootSubmenuKeys
.
indexOf
(
latestOpenKey
)
===
-
1
)
{
if
(
this
.
rootSubmenuKeys
.
indexOf
(
latestOpenKey
)
===
-
1
)
{
this
.
openKeys
=
openKeys
this
.
openKeys
=
openKeys
}
else
{
}
else
{
this
.
openKeys
=
latestOpenKey
?
[
latestOpenKey
]
:
[]
this
.
openKeys
=
latestOpenKey
?
[
latestOpenKey
]
:
[]
}
}
},
},
updateMenu
()
{
updateMenu
()
{
let
routes
=
this
.
$route
.
matched
.
concat
()
let
routes
=
this
.
$route
.
matched
.
concat
()
this
.
selectedKeys
=
[
routes
.
pop
().
path
]
this
.
selectedKeys
=
[
routes
.
pop
().
path
]
let
openKeys
=
[]
let
openKeys
=
[]
routes
.
forEach
((
item
)
=>
{
routes
.
forEach
((
item
)
=>
{
openKeys
.
push
(
item
.
path
)
openKeys
.
push
(
item
.
path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment