Bry*_*ump 5 reactjs material-ui react-router-dom
使用实施路由的最佳实践是material-ui@next什么?在以前的版本中,我可以使用containerElement,Link但不再起作用。在文档中找不到任何帮助。
<MenuItem containerElement={<Link to="/myRoute" />}>My Link</MenuItem>
Run Code Online (Sandbox Code Playgroud)
小智 11
你现在可以MenuItem像这样给一个组件道具:
<MenuItem component={Link} to='/myRoute'>
go to my route
</MenuItem>
Run Code Online (Sandbox Code Playgroud)
您可以将其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>
Run Code Online (Sandbox Code Playgroud)
检查正在运行的演示(请参阅demo.js文件)。