Commit 1a46c6e9 authored by hzq's avatar hzq Committed by 陈帅

Update SiderMenu.js

当权限子菜单无权限或不存在子菜单时不展示父菜单
parent a28a71e9
...@@ -113,6 +113,9 @@ export default class SiderMenu extends PureComponent { ...@@ -113,6 +113,9 @@ export default class SiderMenu extends PureComponent {
*/ */
getSubMenuOrItem = (item) => { getSubMenuOrItem = (item) => {
if (item.children && item.children.some(child => child.name)) { if (item.children && item.children.some(child => child.name)) {
const childrenItems = this.getNavMenuItems(item.children);
// 当无子菜单时就不展示菜单
if (childrenItems && childrenItems.length > 0) {
return ( return (
<SubMenu <SubMenu
title={ title={
...@@ -127,9 +130,10 @@ export default class SiderMenu extends PureComponent { ...@@ -127,9 +130,10 @@ export default class SiderMenu extends PureComponent {
} }
key={item.path} key={item.path}
> >
{this.getNavMenuItems(item.children)} {childrenItems}
</SubMenu> </SubMenu>
); )
}
} else { } else {
return ( return (
<Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item> <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment