Skip to content
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的配置,自定义menuItemRender方法,在边栏展开时,会出现残影 #8902

Open
dengxp opened this issue Dec 4, 2024 · 2 comments

Comments

@dengxp
Copy link

dengxp commented Dec 4, 2024

在app.tsx中,进行layout的配置:

export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
    ....
        menuItemRender: (menuItemProps, defaultDom, props) => {
      if (menuItemProps.isUrl || !menuItemProps.path || (!menuItemProps.children && menuItemProps.parentId === 'max-tabs')) {
        return defaultDom;
      }
      return <Link to={menuItemProps.path}>
        <Space>
          <span>{menuItemProps.icon}</span>
          <span className={'ml-1'}>{menuItemProps.name}</span>
        </Space>
      </Link>
    },
    ...
}

这里通过自定义菜单项的渲染方法:menuItemRender,主要是实现对于子菜单,也支持图标,因为正常情况下,子菜单的图标就算配置了,也是不显示的,如果直接返回defaultDom,就不会出现残影,比如:
menuItemRender: (menuItemProps, defaultDom, props) => {
return defaultDom;
}

© 版本信息

  • ProComponents 版本: [2.6.48]
  • umi 版本: "@umijs/max": "^4.1.1",
  • 浏览器环境:Chrome 131.0.6778.86(正式版本) (arm64)
  • 开发环境 [mac OS Cursor ]

🚑 其他信息

image
@dengxp
Copy link
Author

dengxp commented Dec 4, 2024

图片是使用录屏时的截图
image

@XianZhengquan
Copy link

补充一个,如果使用自己控制菜单的展开、折叠,那么动画会卡的批爆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants