小程序token回调问题

Posted zimukong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小程序token回调问题相关的知识,希望对你有一定的参考价值。

App({
  onLaunch: function(options) {
  },

  wxLogin() { 
    let that = this;
    return new Promise((resolve, reject) => {
      wx.request({
        url: ‘www.xx.com‘,
        success: function(res) {
           that.globalData.web_name = ‘222‘
           resolve(res.data)
        }
      })
    })
  }, 
  globalData: {
    web_name: ‘111‘
  }
})

 

//index.js
const app = getApp()
Page({
  data: {
  },
  onLoad(){ 
     console.log(‘first:‘, app.globalData.web_name)     //111
     app.wxLogin().then(res => {      
       console.log(‘second:‘, app.globalData.web_name) //222
    });
     console.log(‘third:‘, app.globalData.web_name)     //111
  }
})




以上是关于小程序token回调问题的主要内容,如果未能解决你的问题,请参考以下文章