1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 微信小程序 wx.request转同步

微信小程序 wx.request转同步

时间:2022-09-05 05:17:52

相关推荐

微信小程序 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})});},

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