小程序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回调问题

上一篇:监控多条微信公众号链接阅读量,并可视化--模拟鼠标键盘


下一篇:小程序获取 图片宽高