伪代码
wx.showLoading()
http.reqeust({
url: '/xxxx',
method: 'get'
}).then(res => {
console.log(res)
}).catch(() => {
wx.showToast({title: '系统异常'})
}).finally((0 => {
wx.hideLoading()
})
网接口异常时,catch里的showToast真机一闪而过。
原因
最新版微信api wx. hideLoading()
默认可以toast和loading混用,原本只是想在finally里吧loading取消掉,结果顺便把catch里的错误提示也给关闭了。
https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideLoading.html
解决
把wx.hideLoading()
改为wx.hideLoading({noConflict: true})