关于在app.js中跳转的我觉得的bug
发布于 5 年前 作者 duanyong 3403 次浏览 来自 问答

在app.js中onLaunch跳转页面,有的时候跳转成功,有的时候跳转失败,我觉得可能是app.json和app.js加载顺序的问题

wx.getUserInfo({
          success: res => {
            console.log(res)
            // 可以将 res 发送给后台解码出 unionId
            this.globalData.userInfo = res.userInfo
 
            // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
            // 所以此处加入 callback 以防止这种情况
            console.log(this.userInfoReadyCallback)

            if (this.userInfoReadyCallback) {


              this.userInfoReadyCallback(res)


            } else if (res.userInfo) {
              wx.navigateTo({
                url: '../index/index',
                success:function(){
 
                },
                fail:function(){
                  that.onLaunch()
                }
              })
               
            }       
          },
          
          }
        })

我这里写的是如果跳转失败了就重新加载onLaunch()  ,我觉得这是一个bug,官方求解

回到顶部