当我用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'})
}
意思就是这个样子,发送请求不等待回调就关闭页面跳转
感谢解答
wx.redirectTo({ url: 'test?id=1'}) 写在success回调里呀
感谢回复,但是
实际情况是我不需要等待后台返回。但是我怕跳转前http请求没有发出去