加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 06:38:46 所属栏目:百科 来源:网络整理
导读:$.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
$.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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读