关于request请求与页面跳转的问题
发布于 5 年前 作者 hcheng 15204 次浏览 来自 问答

当我用request调取后台接口的时候,如果同时进行了页面的replace,此时有没有可能接口调取失败(我的理解是http请求未发出页面【原因是http没有建立链接】

就已经跳转)

有没有人可以解答下呢,感谢。


具体代码实现是:

function(){

wx.request({  url: 'test.php', // 仅为示例,并非真实的接口地址

 data: {    x: '',    y: ''  },  header: {    'content-type': 'application/json' // 默认值  },  success(res) {    console.log(res.data)  }

})

wx.redirectTo({  url: 'test?id=1'})

}


意思就是这个样子,发送请求不等待回调就关闭页面跳转


感谢解答

1 回复

wx.redirectTo({  url: ‘test?id=1’}) 写在success回调里呀

回到顶部