报错: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)
推荐阅读
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
npm ERR! Cannot read property 'path' of null
-
js报错 Cannot read property 'getAttribute' of null
-
微信小程序报Cannot read property 'setData' of undefined的错误
-
webpack报错Cannot read property 'presetToOptions' of undefined
-
Extjs4---Uncaught TypeError: Cannot read property ‘items’ of undefined
-
JavaScript Uncaught TypeError: Cannot read property 'value' of null
-
Cannot read property 'tap' of undefined
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#
-
el-tooltip组件中content使用Vue-i18n报错TypeError: Cannot read property ‘$t‘ of null