小白使用React---ajax请求成功后跳转到另一个页面

来源:互联网 发布:手机淘宝评价删除不了 编辑:程序博客网 时间:2024/06/05 23:55
$.ajax({                type:"GET",                url:this.url,                dataType:"json",                success:function (result) {                    if(result.meta.success===true){                        that.setState({contents: result.data});                        let content=JSON.stringify(result.data);                        localStorage.setItem("searchlists",content);                        that.props.history.push( '/srmp/v1/contents',null)                    }                },                error:function(xhr,status, err) {                    console.error( status, err.toString());                    // hashHistory.push('/srmp/v1/contents')                    // const win = window.open('/srmp/v1/contents', '_blank');                    // win.focus();                    // browserHistory.push('/srmp/v1/contents');                    // that.props.history.push( '/srmp/v1/contents',null)                }            });

加红色的这句话

第一个参数是跳转路由,path

第二个参数是state,想要传入的参数


路由传参的三种方法

http://blog.csdn.net/qq_23158083/article/details/68488831