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'
})
}
})
}
就可以了