除了hideloading能取消showloading事件之外,有没有其他情况
发布于 6 年前 作者 xiulanduan 12165 次浏览 来自 问答

除了hideloading能取消showloading事件之外,有没有其他情况也会取消showloading;

各位道友有没有碰到过.我写了showloading事件;在没走到hideloading的时候就自己没了,特别是一打开这个页面的时候.(在打开这个页面的时候会有多次showloading事件,但是还没到hideloading就已经没了)

10 回复

没用过.教教我…

一个页面请求了三个action ;分别是10001,10002,10003,10001最慢;但是showloading在10001success回调之前就结束了;

那就不是很明白了,有没有加断点调试一下?

好的.我试试.谢谢

因为其他action进入success方法调用了hideLoading吧,因为是异步请求

现在我把else下面的hideloading都去了;依旧没有showloading

选中调试器,

出来调试工具,选择sources左侧目录选择要调试的js文件,

左键点击要监视的行,然后运行代码

function request(data, fun) {

    wx.showLoading({

    title: ‘加载中’,

    })

    if (data.action == 10002 || data.action == 10003 || data.action == 50001 || data.action == 60005 ) {

            data.shopid = shopid;

            data = JSON.stringify(data);

            wx.request({

                url: url + ‘index.php/Api/Index/index’,

                data: {

                data: data

                },

                method: “POST”,

                header: {

                “Content-Type”: “application/x-www-form-urlencoded”

                },

                success: function (res) {

                    if (fun) {

                        fun(res.data);

                    }

                }

             })

        } else {

        data.shopid = shopid;

        data = JSON.stringify(data);

        

        wx.request({

            url: url + ‘index.php/Api/Index/index’,

            data: {

            data: data

            },

            method: “POST”,

            header: {

            “Content-Type”: “application/x-www-form-urlencoded”

            },

            success: function (res) {

                wx.hideLoading();

                if (fun) {

                    fun(res.data);

                }

            }

        })

    }

}

这个页面总共就三个action,10002和10003没有取消showloading;但是showloading还是会消失的很快;

没有遇到过,贴下你的代码

回到顶部