美文网首页
React router跳转

React router跳转

作者: Fintecher | 来源:发表于2018-06-26 11:22 被阅读14次

    最新版的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'); 跳转

    相关文章

      网友评论

          本文标题:React router跳转

          本文链接:https://www.haomeiwen.com/subject/nbmpyftx.html