微信小程序 请求超时处理

1、在app.json加入一句

"networkTimeout": {
"request": 10000
}
设置超时时间,单位毫秒
2、请求
wx.request时超时会进入fail方法
 
fail: function () {
wx.hideLoading();
wx.showModal({
title: '提示',
showCancel: false,
content: '请求超时,请退出重新扫码!',
success: function () {
wx.redirectTo({
url: '../scan/scan'
})
}
})
}
 
就可以了
posted @ 2019-06-12 11:00  蒲涛-  阅读(14083)  评论(0编辑  收藏  举报