使用了Ant Design,menu的数据改为从后台获取,现在子菜单点击后,没有选中;但是鼠标移入有移入事件。不知道这有没有啥问题。
render() {
const {
openKeys,
theme,
mode,
location: { pathname },
} = this.props;
// if pathname can't match, use the nearest parent's key
let selectedKeys = this.getSelectedMenuKeys(pathname);
if (!selectedKeys.length && openKeys) {
selectedKeys = [openKeys[openKeys.length - 1]];
}
let props = {};
if (openKeys) {
props = {
openKeys,
};
}
const { handleOpenChange, style, menuData } = this.props;
return (
<Menu
key="Menu"
mode={mode}
theme={theme}
onOpenChange={handleOpenChange}
selectedKeys={selectedKeys}
style={style}
className={mode === 'horizontal' ? 'top-nav-menu' : ''}
onClick={this.onClick.bind(this.className)}
{...props}
>
{this.getNavMenuItems(menuData)}
</Menu>
);
}