失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 微信小程序 wx.request转同步

微信小程序 wx.request转同步

时间:2020-07-18 08:19:24

相关推荐

微信小程序 wx.request转同步

微信小程序,将wx.request请求设置为同步,等待其执行结果:

forholiday(){var that = this;return new Promise(function(resolve,reject){wx.request({url: 'http://...', method: 'GET',success: (res) => {resolve(res) },fail(err){}})})},forweekend(){var that = this;return new Promise(function(resolve,reject){wx.request({url: 'https://....', method: 'GET',success: (res) => {resolve(res.data.data.list) },fail(err){reject(err)}})})},holidayInit: async function(){await this.forweekend().then((res) =>{this.setData({weekend: res,workday: true})});await this.forholiday().then((res) =>{this.setData({holiday: res})});},

如果觉得《微信小程序 wx.request转同步》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。