由于父组件没有传给子组件history的值,所以会报错
方法1:父组件加上history={this.props.history}(我用没好使)
方法2:子组件import { withRouter } from ‘react-router’
export default withRouter(Index)
this.props.history.push报错push undefined
最新推荐文章于 2022-11-15 22:06:03 发布
由于父组件没有传给子组件history的值,所以会报错
方法1:父组件加上history={this.props.history}(我用没好使)
方法2:子组件import { withRouter } from ‘react-router’
export default withRouter(Index)