react-router-dom报错:Cannot read property ‘push‘ of undefined
在react项目中进行路由跳转
this.props.history.push('/accountManage');
报错:
Cannot read property ‘push‘ of undefined
解决方法:
//导入withRouter
import {withRouter} from 'react-router-dom'
class AddAccount extends Component{
}
export default withRouter(AddAccount)
本文讲述了在React项目中遇到'Cannot read property 'push' of undefined'错误,通过导入并使用`withRouter`解决在组件中进行路由跳转的问题,确保正确使用路由功能。

1643

被折叠的 条评论
为什么被折叠?



