当前位置:网站首页>微信小程序将原生请求通过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
边栏推荐
猜你喜欢
帆软中使用if else 进行判断-使用标题条件进行判断
VMware installation 64 bit XP Chinese tutorial
Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动
字节面试编程题:最小的K个数
How QT designer adds resource files
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
KVM学习资源
HyperBDR云容灾V3.3.0版本发布|容灾功能升级,资源组管理功能优化
Operation instructions of star boundary text automatic translator
关于NodeJS中JSON5的相关配置和使用
随机推荐
Research on recyclerview details - Discussion and repair of recyclerview click dislocation
ie8 浏览器提示是否 阻止访问js脚本
Wechat applet communicates with low-power Bluetooth - sending data to hardware (III)
倒计时1天~2022云容灾产品线上发布会即将开始
Redis数据库讲解(一)
关于NodeJS中JSON5的相关配置和使用
报表FCRA考试题集及答案(错了11题)
MySQL基础知识
OpenStack如何跨版本升级
在MAC上安装mysql
Five ways of using synchronized to remove clouds and fog are introduced
dp-[NOIP2000]方格取数
Request module
统信UOS卸载php7.2.24,安装php7.4.27 ;卸载再安装为PHP 7.2.34
jsp学习3
findstr不是内部或外部命令解决方法
Recyclerview advanced use (I) - simple implementation of sideslip deletion
1到100号的灯开关问题
Wechat applet input hidden and inoperable settings
STD:: map and STD:: vector memory free