我是靠谱客的博主 疯狂手链,这篇文章主要介绍uni uni.showloding uni.showtoast 冲突的问题,现在分享给大家,希望可以做个参考。

uni项目中是使用了
uni.showLoading({
title: ‘数据加载中…’
})
uni.hideLoading()
在请求完成之后给用户提示信息 出现冲突 提示信息不显示

// 导入网络请求的包
import {
$http
} from '@escook/request-miniprogram'
uni.$http = $http
// 请求的根路径
// $http.baseUrl = 'http://192.168.0.128:8999/vehicle'
// $http.baseUrl = 'http://127.0.0.1/vehicle'
$http.baseUrl = 'https://www.fanzegroup.com/vehicle'
// 请求拦截器
$http.beforeRequest = function(options) {
uni.showLoading({
title: '数据加载中...'
})
}
// 响应拦截器
$http.afterRequest = function(res) {
// console.log(res, '获取响应信息');
if (res.statusCode == 403) {
uni.clearStorageSync();
uni.navigateTo({
url: '/pages/login/login.vue'
})
}
// plus.nativeUI.closeWaiting();
uni.hideLoading()
}
// 封装弹框的方法
uni.$showMsg = function(title = '数据请求失败!', icon = 'none', duration = 1500) {
setTimeout(()=> {
uni.showToast({
title,
icon,
duration,
})
},0)
}
// 在页面发送请求的时候封装了 一个请求拦截器 响应拦截器 
// 解决方法
调用uni.showToast的时候加一个定时器
setTimeout(()=> {
uni.showToast({
title,
icon,
duration,
})
},0)

写作不易 点个赞再走

最后

以上就是疯狂手链最近收集整理的关于uni uni.showloding uni.showtoast 冲突的问题的全部内容,更多相关uni内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(111)

评论列表共有 0 条评论

立即
投稿
返回
顶部