当前位置:网站首页>The request request is encapsulated in uni app, which is easy to understand
The request request is encapsulated in uni app, which is easy to understand
2022-07-07 04:23:00 【Little ape classmate】
1.uni-app It's a vue Develop a framework for all front-end applications , Developers write a set of code , Can be posted to iOS、Android、Web( Response type )、 And all kinds of little programs ( WeChat / Alipay / Baidu / headlines / anonymous letter /QQ/ Well quickly / nailing / TaoBao )、 Fast application and other platforms .
2. In my opinion, it is vue Syntax of plus applet api, It's a combination of .
3. Enter today's focus , What I want to share is uniapp Middle package request request .
We need to build a new one first utils Folder , And then create a api.js.

The contents of the document are as follows : The default export arrow function
const myRequest = (obj)=>{
return new Promise((resolve,reject)=>{
uni.request({
url:obj.url,
method:obj.method,
data:obj.data||{},
success(res) {
resolve(res.data)
},
fail(err) {
reject(err)
}
})
})
}
export default myRequestThen go to main.js Register globally in .

Now you can use it in the page .
async getlist(did) {
let res = await this.$myReq({
url:'http://ludir.cn/api/webapi/public/index/details?typeId=' + did,
methods:'get'
})
this.list = res
},边栏推荐
- [untitled]
- EasyCVR无法使用WebRTC进行播放,该如何解决?
- Using thread class and runnable interface to realize the difference between multithreading
- Operational amplifier application summary 1
- pyqt5 失焦 监听无操作 定时器
- Unity3D在一建筑GL材料可以改变颜色和显示样本
- 测试/开发程序员怎么升职?从无到有,从薄变厚.......
- [record of question brushing] 2 Add two numbers
- Optimization of channel status offline of other server devices caused by easycvr cluster restart
- Practice Guide for interface automation testing (middle): what are the interface testing scenarios
猜你喜欢

Optimization of channel status offline of other server devices caused by easycvr cluster restart

Storage of data

Mathematical analysis_ Notes_ Chapter 10: integral with parameters

接口自动化测试实践指导(中):接口测试场景有哪些

5年自动化测试,终于进字节跳动了,年薪30w其实也并非触不可及

See Gardenia minor

Analysis on urban transportation ideas of 2022 Zhongqing cup C

【写给初发论文的人】撰写综述性科技论文常见问题

SSM+JSP实现企业管理系统(OA管理系统源码+数据库+文档+PPT)

Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
随机推荐
The most complete deployment of mongodb in history
2022 middle school Youth Cup mathematical modeling question B fertility policy research ideas under the background of open three children
【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
【OA】Excel 文档生成器: Openpyxl 模块
【编码字体系列】OpenDyslexic字体
Web service performance monitoring scheme
史上最全MongoDB之部署篇
2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
[coded font series] opendyslexic font
用头像模仿天狗食月
Hangzhou Electric 3711 binary number
史上最全MongoDB之Mongo Shell使用
PHP implements lottery according to probability
高薪程序员&面试题精讲系列120之Redis集群原理你熟悉吗?如何保证Redis的高可用(上)?
EasyCVR视频广场点击播放时,主菜单高亮效果消失问题的修复
超越Postman,新一代国产调试工具Apifox,用起来够优雅
In cooperation with the research team of the clinical trial center of the University of Hong Kong and Hong Kong Gangyi hospital, Kexing launched the clinical trial of Omicron specific inactivated vacc
[team learning] [34 issues] scratch (Level 2)
PHP 实现根据概率抽奖
Kotlin Compose Text支持两种颜色