当前位置:网站首页>微信小程序将原生请求通过es6的promise来进行优化
微信小程序将原生请求通过es6的promise来进行优化
2022-04-23 14:10:00 【瑞瑞小同学】
在request文件夹中新建index.js

在需要的page页面进行引入,比如我的首页轮播图数据
代码:index.js
export const request = (params) => {
return new Promise((resolve,reject) => {
wx.request({
...params,
success:(result)=>{
resolve(result)
},
fail:(err)=>{
reject(err)
}
})
})
}
版权声明
本文为[瑞瑞小同学]所创,转载请带上原文链接,感谢
https://blog.csdn.net/yr123456654321/article/details/109034002
边栏推荐
猜你喜欢

win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件

ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory

Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动

On the multi-level certificate based on OpenSSL, the issuance and management of multi-level Ca, and two-way authentication

连接公司跳板机取别名

MySQL数据库讲解(十)

sql中出现一个变态问题

微信小程序客服接入,实现发送和接收消息

VMware Workstation 无法连接到虚拟机。系统找不到指定的文件

星界边境文本自动翻译机(高级版)使用说明
随机推荐
mysql 5.1升级到5.611
elk安装
关于训练过程中损失函数出现断崖式增长的问题
Some good articles on pthread multithreading
金融行业云迁移实践 平安金融云整合HyperMotion云迁移解决方案,为金融行业客户提供迁移服务
mysql查询库大小
Redis数据库讲解(一)
帆软中根据分类进行汇总
MySQL数据库讲解(七)
Research on recyclerview details - Discussion and repair of recyclerview click dislocation
HyperBDR云容灾V3.2.1版本发布|支持更多云平台,新增监控告警功能
利用json-server在本地创建服务器请求
ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory
关于Jmeter启动闪退问题
Some experience of using dialogfragment and anti stepping pit experience (getactivity and getdialog are empty, cancelable is invalid, etc.)
xx项目架构随记
使用开源调研工具Prophet是一种什么体验?
RecyclerView高级使用(二)-垂直拖拽排序的简单实现
How to do a project easily
redis数据库讲解(三)redis数据类型