React中子组件无法进行路由跳转的问题



1、子组件引入withRouter
2、跳转路由this.props.history.push(’/’);
3、加入: export default withRouter(Title);

import {withRouter} from "react-router-dom";

class Title extends Component {
 outLogin = () => {     
 //跳转路由     
  this.props.history.push('/');   
   }
  }
export
default withRouter(Title);




原文链接:https://blog.csdn.net/Hei_lovely_cat/java/article/details/104038229

猜你喜欢

转载自www.cnblogs.com/lyablog/p/12952666.html