diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 072f5cea9eb4326ea3e0dafd0abde9c18a3311b2..f9abebcdea60de44326db90ac9b68d86a6b86c76 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -113,23 +113,27 @@ export default class SiderMenu extends PureComponent { */ getSubMenuOrItem = (item) => { if (item.children && item.children.some(child => child.name)) { - return ( - - {getIcon(item.icon)} - {item.name} - - ) : ( - item.name - ) - } - key={item.path} - > - {this.getNavMenuItems(item.children)} - - ); + const childrenItems = this.getNavMenuItems(item.children); + // 当无子菜单时就不展示菜单 + if (childrenItems && childrenItems.length > 0) { + return ( + + {getIcon(item.icon)} + {item.name} + + ) : ( + item.name + ) + } + key={item.path} + > + {childrenItems} + + ) + } } else { return ( {this.getMenuItemPath(item)}