当前位置:网站首页>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
},边栏推荐
- [on automation experience] the growth path of automated testing
- 史上最全MongoDB之部署篇
- Kotlin Compose Text支持两种颜色
- Hangzhou Electric 3711 binary number
- C#使用西门子S7 协议读写PLC DB块
- 【自动化经验谈】自动化测试成长之路
- Collection of idea gradle Lombok errors
- Redis configuration and optimization of NoSQL
- 测试/开发程序员怎么升职?从无到有,从薄变厚.......
- Food Chem | in depth learning accurately predicts food categories and nutritional components based on ingredient statements
猜你喜欢

【写给初发论文的人】撰写综述性科技论文常见问题
![[on automation experience] the growth path of automated testing](/img/28/38d82cbdc7ed249d376fff264d1b5d.png)
[on automation experience] the growth path of automated testing

Why does WordPress open so slowly?

The easycvr platform is connected to the RTMP protocol, and the interface call prompts how to solve the error of obtaining video recording?

英特尔David Tuhy:英特尔傲腾技术成功的原因

Mongo shell, the most complete mongodb in history

EasyCVR集群重启导致其他服务器设备通道状态离线情况的优化

Win11图片打不开怎么办?Win11无法打开图片的修复方法

Dab-detr: dynamic anchor boxes are better queries for Detr translation

Easycvr cannot be played using webrtc. How to solve it?
随机推荐
ABAP Dynamic Inner table Group cycle
The most complete security certification of mongodb in history
EasyCVR视频广场点击播放时,主菜单高亮效果消失问题的修复
[knife-4j quickly build swagger]
Win11远程桌面连接怎么打开?Win11远程桌面连接的五种方法
机器人(自动化)课程的持续学习-2022-
SSM+jsp实现仓库管理系统,界面那叫一个优雅
案例大赏:英特尔携众多合作伙伴推动多领域AI产业创新发展
【刷题记录】2. 两数相加
Mongo shell, the most complete mongodb in history
MySQL data loss, analyze binlog log file
pyqt5 失焦 监听无操作 定时器
CUDA Programming
史上最全MongoDB之初识篇
C#使用西门子S7 协议读写PLC DB块
Continuous learning of Robotics (Automation) - 2022-
NFT meta universe chain diversified ecosystem development case
EasyCVR无法使用WebRTC进行播放,该如何解决?
buildroot的根文件系统提示“depmod:applt not found”
Optimization of channel status offline of other server devices caused by easycvr cluster restart