React router跳转

2018-06-26  本文已影响14人  Fintecher

最新版的React需要安装npm i react-prop-types -s

static contextTypes={  
        router:React.PropTypes.object  
    }  
    constructor(props,context){  
        super(props,context);  
        this.context.router;  
    }  

这样就可以this.context.router.history.push('/page'); 跳转

constructor(props, context) {
        super(props, context);
    }

这样就可以this.props.history.push('/page'); 跳转

上一篇下一篇

猜你喜欢

热点阅读