【问题标题】:MenuItem containerElement Links broken after upgrading to v1 material-ui升级到 v1 material-ui 后,MenuItem containerElement 链接断开
【发布时间】:2018-01-26 03:27:25
【问题描述】:

旧菜单项被 react-router-dom 破坏

     <MenuItem
                containerElement={<Link to="/module" />} >Module</MenuItem>

这停止工作....

如何升级这些新的菜单项控件以使用 react-router?

我尝试将 containerElement 替换为 root,并用标签包围,但超链接带有下划线。我想保持与 MenuItem 相同的样式。

【问题讨论】:

    标签: material-ui react-router-dom


    【解决方案1】:

    来自这篇文章:How to do routing with material-ui@next MenuItem?

    从这里查看 demo.js https://codesandbox.io/s/5213wzkvpl

    您可以将链接用作 MenuItem 的子项:

    <MenuList>
      <MenuItem>
        <Link to="/myRoute" style={{ textDecoration: 'none', display: 'flex' }}>
          go to my route
        </Link>
      </MenuItem>
    </MenuList>
    

    【讨论】:

      猜你喜欢
      • 2022-08-04
      • 2017-09-02
      • 2019-10-10
      • 2018-12-16
      • 1970-01-01
      • 1970-01-01
      • 2018-04-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多