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

🐛[BUG]从服务器请求菜单文档提供方法菜单不显示 #7530

Closed
lcosmos opened this issue Oct 27, 2020 · 8 comments
Closed

🐛[BUG]从服务器请求菜单文档提供方法菜单不显示 #7530

lcosmos opened this issue Oct 27, 2020 · 8 comments
Labels

Comments

@lcosmos
Copy link

lcosmos commented Oct 27, 2020

🐛 bug 描述

文档地址

今天删除了node_modules重新拉取新的包后,按上述文档地址切换成动态路由后菜单不显示。

📷 复现步骤

使用最新的antd pro,按找文档方式修改服务器请求菜单,菜单不显示。

🏞 期望结果

菜单能够正常显示

💻 复现代码

© 版本信息

  • Ant Design Pro 版本: 4.2.2
  • umi 版本:3.2.4
  • 浏览器环境:Chrome 86.0.4240.111(正式版本)
  • 开发环境 mac OS

🚑 其他信息

@lcosmos
Copy link
Author

lcosmos commented Oct 27, 2020

@ant-design/pro-layout 6.5.5没问题哦
6.5.6有问题 目测下面这段代码问题
image

@xiaofsu
Copy link

xiaofsu commented Oct 30, 2020

+1

@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Nov 2, 2020

模仿这个来
https://procomponents.ant.design/components/layout#%E4%BB%8E%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%8A%A0%E8%BD%BD-menu

通过 loading 来让layout 重新渲染,不然会有性能问题

     <ProLayout
        style={{
          height: 400,
          border: '1px solid #ddd',
        }}
        menu={{
          loading,
        }}
        location={{
          pathname: '/welcome/welcome',
        }}
        menuDataRender={() => menuData}
      >
        <PageContainer content="欢迎使用">Hello World</PageContainer>
      </ProLayout>

@wxuonline
Copy link

menu={{ loading }}
会被 {...settings} 中的menu覆盖,找半天才找到问题...

@daifuyang
Copy link

这个问题我之前解决了!有两个坑!
第一步:删除config/defaultSettings.js中的menu,第二步menu={{ loading }}

@lee-li
Copy link

lee-li commented Nov 26, 2020

@daifuyang 👍 确实!

@johnstevin
Copy link

menu={{ loading }}
会被 {...settings} 中的menu覆盖,找半天才找到问题...

这个问题我找了整一天,才解决,全是泪啊!

@tigerxiongj
Copy link

这个问题确实坑,今天升级了antd pro和antd版本,发现以前的menuDataRender在组件mount之后不会再次调用。
除了上面的menu.loading之外,我自己搞了一个。
// async componentWillMount() {
// const response = await queryAuthorities();
// let data = response.data;
// if (data) {
// const authorities = data.map(itm => itm.menuTag);
// setAuthority(authorities);
// }
// }
在组件加载之前,先获取权限配置。

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

No branches or pull requests

8 participants