欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

报错:Cannot read property ‘push‘ of undefined

程序员文章站 2022-07-03 10:39:21
...

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 react