https://ant.design/components/menu-cn/#API
meue有一个问题,当页面刷新后,当前选中的状态消失了,解决方案,给对应的层级添加对应的带有selected的类名
<Menu style={{ width: 72 }} mode="vertical" theme="dark">
<li className='uba-logo-wrapper'>
<span className="logo">
<img src={logo} alt="" />
</span>
</li>
{permissionRoutes.filter(routeItem => !routeItem.path.includes('userScan/:id')).map((routeItem, indexOut) => (
<SubMenu key={routeItem.name} icon={<IconFont type={routeItem.icon} />} title={routeItem.text} className={ClassNames(routeItem.name, { 'udesk-ui-menu-submenu-selected': location.pathname.indexOf(routeItem.path) !== -1 })} >
{routeItem.routes.map(item => (
<Menu.Item key={item.name} className={ClassNames({ 'udesk-ui-menu-item-selected': location.pathname.indexOf(item.path) !== -1 })}>
<Link to={item.path}>
<span className="title-text">{item.text}</span>
</Link>
</Menu.Item>
)
)}
</SubMenu>
))}
</Menu>
网友评论