叫啥好呢
叫啥好呢
  • 发布:2023-04-13 10:11
  • 更新:2023-04-13 10:27
  • 阅读:326

【报Bug】uni.showLoading 会先uni.hideLoading 再showLoading

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 64

HBuilderX类型: 正式

HBuilderX版本号: 3.7.13

手机系统: Android

手机系统版本号: Android 12

手机厂商: 小米

手机机型: 小米10

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.showLoading()

setTimeOut(() => {uni.showLoading()}, 2000)

操作步骤:

uni.showLoading()

setTimeOut(() => {uni.showLoading()}, 2000)

预期结果:

再次调用showLoading 不会先调用hideLoading
会闪一下
或者能判断下 loading在显示中

实际结果:

多次调用showLoading 会闪 再显示

bug描述:

uni.showLoading 会先uni.hideLoading 再showLoading

小程序不会

2023-04-13 10:11 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

先 hideLoading 再 showLoading 是为了防止重复多个 loading
上述调用的需求场景是什么呢

  • 叫啥好呢 (作者)

    请求时候 我这请求没办法判断loading 是否在显示中啊 多个接口同时请求 在最后一个请求后关闭loading 其他不关闭

    2023-04-18 14:58

  • 叫啥好呢 (作者)

    loading 我是封装到请求中的

    2023-04-18 14:58

  • 叫啥好呢 (作者)

    在小程序上 没这个问题

    2023-04-18 14:58

  • DCloud_UNI_WZF

    回复 叫啥好呢: 感觉 loading 的逻辑不应该封死在请求函数中

    可以在发起请求前触发一次showLoading, 利用 promise.all hideLoading

    或者状态管理中有个标记请求中个数的数据,基于它的状态操作 loading

    2023-04-18 15:22

  • 叫啥好呢 (作者)

    回复 DCloud_UNI_WZF: 不能和小程序一样吗

    2023-04-18 15:23

  • DCloud_UNI_WZF

    回复 叫啥好呢: 暂没有调整该逻辑的计划

    小程序对应api 由小程序实现,web 及 app 端由框架实现,宿主环境不同,实现逻辑可能存在差异

    2023-04-18 16:02

  • 叫啥好呢 (作者)

    回复 DCloud_UNI_WZF: 原先我记着 多次调用showLoading 不会有这个问题的啊

    2023-04-18 17:16

  • 叫啥好呢 (作者)

    不知道什么时候改成这样了

    2023-04-18 17:17

  • 4***@qq.com

    回复 叫啥好呢: 您好这个问题解决了吗?我也遇到了

    2023-09-20 11:24

要回复问题请先登录注册