各种找最后发现在complete回调里。。。。。。
wx.request({
url: 'example.php', //仅为示例,并非真实的接口地址
data: {
x: '',
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
console.log(res.data)
},
complete(res){
if(res.statusCode==500){ //服务器500错误,其他错误码应该也走这里
wx.showModal({
confirmColor: "#ff9500",
showCancel: false,
content: "服务器故障,请稍后再试",
confirmText: '我知道了',
})
}
}
})