当前位置:网站首页>微信小程序将原生请求通过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
边栏推荐
猜你喜欢

How QT designer adds resource files

PySide2

帆软中单元格中隔行变色以及数量大于100字体变大变红设置

MySQL数据库讲解(七)

Wechat applet initializes Bluetooth, searches nearby Bluetooth devices and connects designated Bluetooth (I)

Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface

教育行业云迁移最佳实践:海云捷迅使用HyperMotion云迁移产品为北京某大学实施渐进式迁移,成功率100%

容灾有疑问?点这里

帆软分割求解:一段字符串,只取其中某个字符(所需要的字段)

正则表达式
随机推荐
关于Jmeter启动闪退问题
JDBC详解
使用DialogFragment的一些感受及防踩坑经验(getActivity、getDialog为空,cancelable无效等)
redis数据库讲解(三)redis数据类型
gzip和gunzip 解压参数详解
man man随记和crontab的@reboot用法
mysql锁数据库锁
Understand the concepts of virtual base class, virtual function and pure virtual function (turn)
Homebrew是什么?以及使用
在Clion中给主函数传入外部参数
findstr不是内部或外部命令解决方法
星界边境Starbound创意工坊订阅的mod的存放路径
帆软中使用if else 进行判断-使用标题条件进行判断
sql中出现一个变态问题
HyperBDR云容灾V3.2.1版本发布|支持更多云平台,新增监控告警功能
数据库DbVisualizer Pro报文件错误,导致数据连接失败
VMWare安装64位XP中文教程
在MAC上安装mysql
Win10 comes with groove music, which can't play cue and ape files. It's a curvilinear way to save the country. It creates its own aimpack plug-in package, and aimp installs DSP plug-in
MySQL-InnoDB-事务