如何使用material-ui @ next MenuItem进行路由? [英] How to do routing with material-ui@next MenuItem?

查看:148
本文介绍了如何使用material-ui @ next MenuItem进行路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用material-ui@next实现路由的最佳实践是什么?在以前的版本中,我可以将containerElementLink结合使用,但不再起作用.在文档中找不到任何帮助.

What's the best practice to implement routing using the material-ui@next? In the previous version I could use containerElement with a Link but doesn't work anymore. Couldn't find any help in the docs.

 <MenuItem containerElement={<Link to="/myRoute" />}>My Link</MenuItem>

推荐答案

您可以将Link用作MenuItem的父组件:

You can use Link as parent component for MenuItem:

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

这篇关于如何使用material-ui @ next MenuItem进行路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆