-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧐[问题]ProLayout左侧菜单 #7093
Comments
🛠 解决方案可以通过自定义菜单项的点击事件来实现想要的效果。 首先,需要在 ProLayout 组件中设置菜单的唯一标识符,例如 <ProLayout
menu={{
// 设置菜单唯一标识符
menuKey: 'menuItemKey',
}}
>
{/* 菜单项 */}
<Menu.Item key="menu-item-1" onClick={handleMenuClick}>
菜单项1
</Menu.Item>
{/* ...其他菜单项 */}
</ProLayout> 然后,在事件处理函数 const handleMenuClick = ({ key }) => {
// 获取当前展开的菜单项
const expandedMenuKey = getMenuExpandedKey();
if (expandedMenuKey !== key) {
if (!isSubMenuExpanded(key)) {
// 如果点击的菜单项处于折叠状态,则展开
toggleSubMenu(key);
} else {
// 如果点击的菜单项处于展开状态,则折叠
toggleSubMenu(key);
}
}
};
// 获取当前展开的菜单项
const getMenuExpandedKey = () => {
// 根据具体项目逻辑获取当前展开的菜单项的 key
};
// 判断菜单项是否处于展开状态
const isSubMenuExpanded = (key) => {
// 根据菜单项的 key 判断是否展开,返回布尔值
};
// 折叠或展开菜单项
const toggleSubMenu = (key) => {
// 根据菜单项的 key 进行折叠或展开操作
}; 以上代码只是一个示例,具体实现需要根据项目的具体情况来进行调整。由于不知道你项目的具体代码结构,所以无法提供更具体的代码示例。 关于 ProLayout 组件的更多信息,请参考 Ant Design Pro 文档。 |
#7372 一起修复啦 |
🧐 问题描述
左侧菜单切换时已经折叠或展开的菜单会收到影响,自动切换折叠和展开的状态
希望达到的效果:手动折叠的菜单,在点击其它菜单的时候不要自动展开;手动展开的菜单,点击其它菜单时不要自动折叠
The text was updated successfully, but these errors were encountered: