TypeError: Cannot read property 'push' of undefined
onClick
F:/study/react/react-admin/src/compoments/Frame/Index.js:44
41 | {routes.map(routes=>{
42 | return (
43 | <Menu.Item key={routes.path}
> 44 | onClick={p=>props.history.push(p.key)} >
| ^ 45 | <IconFont type={routes.icon} />
46 | {routes.title}
47 | </Menu.Item>
View compiled
出现这个问题是因为我们没有引入withRouter
我们引入即可
import { withRouter } from 'react-router-dom' export default withRouter(Index)
文章评论(0)