更新版本以后 onShow()报错
发布于 6 年前 作者 ming23 9820 次浏览 来自 问答

刚刚更新了版本,完了以后报了这个错,我把onShow()注释了还是报错,想请教一下这是什么问题?

5 回复

不是自己定义的方法呢

Page({
    data:{
        userMsg:{},
        userPoster:’’,
        userInfo:{},
        userData:{}
    },
    onLoad: function(){
    },
   __ onShow__: function() {
      var that = this;
       wx.getStorage({
            key: ‘userBase’,
            success: function(res) {
                that.setData({
                    userMsg:res.data
                });
                userId = res.data.user_id;
                token = res.data.token;
                console.log(userId,token);
                //1、请求用户空间壁纸接口
                wx.request({
                    url: theme_url + ‘&user_id=’ + userId + ‘&token=’ + token ,
                    data: {},
                    header: {
                        ‘Content-Type’ : ‘application/json’
                    },
                    success: function(resp){
                        var data = resp.data;
                        console.log(data.content);
                        that.setData({
                            userPoster:data.content.theme_url
                        });
                    }
                })
                //2、请求用户信息接口
                wx.request({
                    url: user_info_url + ‘&user_id=’ + userId + ‘&token=’ + token ,
                    data: {},
                    header: {
                        ‘Content-Type’ : ‘application/json’
                    },
                    success: function(resp){
                        var data = resp.data;
                        that.setData({
                            userInfo:data.content
                        });
                        console.log(data);
                    }
                })
                //3、请求用户数据报告接口
                wx.request({
                    url: user_count_url + ‘&user_id=’ + userId + ‘&token=’ + token ,
                    data: {},
                    header: {
                        ‘Content-Type’ : ‘application/json’
                    },
                    success: function(resp){
                        var data = resp.data;
                        that.setData({
                            userData:data.content
                        });
                        console.log(data);
                    }
                })
            }
       })
    }
})

我遇到过类似的问题,是因为自己的代码里调用方法没加()导致编译后出现onShow:function onShow(){}

确实有这个问题  已经fixed 了

2017.01.05 更新日志

基础库更新

  1. F: 修复 API wx.switchTab 后 onShow 没有触发的问题

  2. F: 修复 touch 事件在开发工具上出现 preventDefault inside passive event 的问题

这个问题 依旧存在,微信版本6.5.13

这个是你自己定义的吧。不是微信内部的方法

回到顶部