收藏
回答

onLoad()中调用wx.hideLoading()不触发回调

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.hideLoading 微信iOS客户端 7.0.17 IOS: 14.0.1 WeChatLib: 2.13.2

onLoad: function (options) {

        wx.showLoading({

            title: '加载中',

            mask: true

        });

        this.fetchBindStatus().then(res => {

wx.hideLoading({

complete: () => {

console.log('我不会被触发');

})

        }, error => {

            return Promise.reject();

        }).catch(error => {

            console.log(error);

        });

    }

尝试了在onReady里面调用可以触发

在onLoad里面延时调用可以触发

为啥onLoad直接调用不行?这是bug还是特性?

回答关注问题邀请回答
收藏

2 个回答

  • 少侠
    少侠
    2020-10-27

    这个在onReady或者onShow的时候试试,或者加一个500ms的延时

    2020-10-27
    有用 1
    回复
  • James¹⁰¹⁴
    James¹⁰¹⁴
    2020-10-27

    会调用的,哪里写的有问题吧。

    onLoad: function (options) {
            wx.showLoading({
                title'加载中...',
                masktrue
            })
            wx.login({}).then(res => {
                console.log(res)
                wx.hideLoading({
                    complete(res) => {
                        console.log('hideLoading - complete');
                        console.log(res);
                    }
                })
            }).catch(err => {
                console.error(err)
            })
        },
    
    2020-10-27
    有用
    回复 3
    • bottom
      bottom
      2020-10-27
      在请求之后调用不行,安卓和开发者工具测试时可以的,我这边IOS就不行
      2020-10-27
      回复
    • James¹⁰¹⁴
      James¹⁰¹⁴
      2020-10-27回复bottom
      试了一下,ios也是可以的呢。
      不行的话就看看是不是加个500毫秒的延迟吧。
      无奈...
      2020-10-27
      回复
    • APRilLOSER
      APRilLOSER
      2021-01-15回复bottom
      wx.hideLoading complete 我这里同样遇到了   回调不执行的情况,大哥是怎么解决的
      2021-01-15
      回复
登录 后发表内容
问题标签