如何用material-ui@next MenuItem做路由?
How to do routing with material-ui@next MenuItem?
使用 material-ui@next
实现路由的最佳做法是什么?在以前的版本中,我可以将 containerElement
与 Link
一起使用,但不再起作用了。在文档中找不到任何帮助。
<MenuItem containerElement={<Link to="/myRoute" />}>My Link</MenuItem>
您可以使用 Link
作为 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>
你现在可以给 MenuItem
一个像这样的组件道具:
<MenuItem component={Link} to='/myRoute'>
go to my route
</MenuItem>
使用 material-ui@next
实现路由的最佳做法是什么?在以前的版本中,我可以将 containerElement
与 Link
一起使用,但不再起作用了。在文档中找不到任何帮助。
<MenuItem containerElement={<Link to="/myRoute" />}>My Link</MenuItem>
您可以使用 Link
作为 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>
你现在可以给 MenuItem
一个像这样的组件道具:
<MenuItem component={Link} to='/myRoute'>
go to my route
</MenuItem>