withRouter将react-router 的 history、location、match 三个对象传入props对象上,
通过withRouter包裹一下子组件 子组件就可以获得react-router 的 history
父组件中需要传入 historys(一个名字)
<GoodFoot historys={this.props.history}> </GoodFoot>
子组件中导入withRouter
import { withRouter } from ‘react-router-dom’
包裹子组件
export default withRouter(子组件名字)
然后就可以使用react-router 的history了
this.props.historys.push(’/路径名称’)