公共方法 get 请求
asyncRequest(url,) {
return new Promise((resolve, reject) => {
uni.request({
url: url,
success(res) {
resolve(res)
},
fail(err){
reject(err)
}
})
})
},
页面调用
async onLoad(options) {
this.data=await this.asyncRequest('https://api-hmugo-web.itheima.net/api/public/v1/home/catitems');
console.log(this.data,"成功");
},