Commit e3cb9b2d authored by 杨伟荣's avatar 杨伟荣 Committed by 陈帅

修复侧边栏菜单不能动态显示的问题

parent 7d68af16
...@@ -51,7 +51,6 @@ export const getMenuMatchKeys = (flatMenuKeys, paths) => ...@@ -51,7 +51,6 @@ export const getMenuMatchKeys = (flatMenuKeys, paths) =>
export default class SiderMenu extends PureComponent { export default class SiderMenu extends PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.menus = props.menuData;
this.flatMenuKeys = getFlatMenuKeys(props.menuData); this.flatMenuKeys = getFlatMenuKeys(props.menuData);
this.state = { this.state = {
openKeys: this.getDefaultCollapsedSubMenus(props), openKeys: this.getDefaultCollapsedSubMenus(props),
...@@ -197,7 +196,7 @@ export default class SiderMenu extends PureComponent { ...@@ -197,7 +196,7 @@ export default class SiderMenu extends PureComponent {
}; };
isMainMenu = key => { isMainMenu = key => {
return this.menus.some(item => key && (item.key === key || item.path === key)); return this.props.menuData.some(item => key && (item.key === key || item.path === key));
}; };
handleOpenChange = openKeys => { handleOpenChange = openKeys => {
...@@ -247,7 +246,7 @@ export default class SiderMenu extends PureComponent { ...@@ -247,7 +246,7 @@ export default class SiderMenu extends PureComponent {
selectedKeys={selectedKeys} selectedKeys={selectedKeys}
style={{ padding: '16px 0', width: '100%' }} style={{ padding: '16px 0', width: '100%' }}
> >
{this.getNavMenuItems(this.menus)} {this.getNavMenuItems(this.props.menuData)}
</Menu> </Menu>
</Sider> </Sider>
); );
......
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