当前位置:网站首页>微信小程序将原生请求通过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
边栏推荐
- STD:: map and STD:: vector memory free
- json date时间日期格式化
- Multiple inheritance virtual base exercises
- 统信UOS卸载php7.2.24,安装php7.4.27 ;卸载再安装为PHP 7.2.34
- 政务云迁移实践 北明数科使用HyperMotion云迁移产品为某政府单位实施上云迁移项目,15天内完成近百套主机迁移
- Wechat applet positioning and ranging through low-power Bluetooth device (2)
- elk安装
- KVM学习资源
- 01-nio basic ByteBuffer and filechannel
- MySQL数据库讲解(九)
猜你喜欢
HyperMotion云迁移完成阿里云专有云产品生态集成认证
Use the executors class to quickly create a thread pool
MySQL数据库讲解(八)
sql中出现一个变态问题
云迁移的六大场景
Idea控制台乱码解决
什么是云迁移?云迁移的四种模式分别是?
VMWare安装64位XP中文教程
Installation and use of postman pit
On the multi-level certificate based on OpenSSL, the issuance and management of multi-level Ca, and two-way authentication
随机推荐
ActiveMq基础知识
Gartner预测云迁移规模大幅增长;云迁移的优势是什么?
MySQL数据库讲解(七)
Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动
On the problem of cliff growth of loss function in the process of training
Pass in external parameters to the main function in clion
拨开云雾synchronized使用五种方式介绍
HyperMotion云迁移助力中国联通,青云完成某央企上云项目,加速该集团核心业务系统上云进程
Multiple inheritance virtual base exercises
How QT designer adds resource files
Logging module
某政务云项目业务系统迁移调研实践
预览CSV文件
win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
帆软分割求解:一段字符串,只取其中某个字符(所需要的字段)
JDBC详解
squid代理
DP energy Necklace
Some experience of using dialogfragment and anti stepping pit experience (getactivity and getdialog are empty, cancelable is invalid, etc.)
Postman的安装使用及填坑心得