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)