首页 > 微信 > 详细

小程序token回调问题

时间:2020-07-24 14:43:06      阅读:109      评论:0      收藏:0      [点我收藏+]
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回调问题

原文:https://www.cnblogs.com/zimukong/p/13371228.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!