小程序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 } })




猜你喜欢

转载自www.cnblogs.com/zimukong/p/13371228.html