// 发送请求
uni.request({
// 请求类型
method: type,
// 请求地址
url: baseApi + url,
// 请求参数
data: data,
// 请求头配置
header: header,
// 数据格式
dataType: 'json',
}).then((response) => {
// 如果请求成功
// 关闭加载loading
setTimeout(function () {
uni.hideLoading();
}, 0);
let [error, res] = response;
resolve(res.data);
}).catch(error => {
// 如果请求错误,关闭加载loading
setTimeout(function () {
uni.hideLoading();
}, 0);
let [err, res] = error;
reject(err)
})
});
解决办法:
setTimeout(() => {
wx.showToast({
icon: 'none',
title: `${retult.msg}`,
duration: 3000
})
}, 100)
为啥真机中一闪而过 因为uni.hideLoading();和wx.showToast用的同一个框子底层,解决办法还是用异步执行顺序来