使用router过程中在子组件想进行路由跳转,使用this.props.history报错,进一步调试发现this.props为undefined,查阅文档得知
没办法通过 this.props.children 取得当前组件的子元素。 因为this.props.children 返回的是组件拥有者传递给你的 passed onto you 子节点。
解决方法:(withRouter)
使用withRouter包裹当前组件
然后就可以跳转了!
没办法通过 this.props.children 取得当前组件的子元素。 因为this.props.children 返回的是组件拥有者传递给你的 passed onto you 子节点。
使用withRouter包裹当前组件
然后就可以跳转了!