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)
              
                
                          
                          
                        
                        
                        
                        
                        
                        
                        
                        
                
                
                        
                        
                        
                        
关于简忆
简忆诞生的故事
            


粤ICP备16092285号
文章评论(0)