当前位置:网站首页>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 myRequest
Then 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
},
边栏推荐
- Golang calculates constellations and signs based on birthdays
- SSM+JSP实现企业管理系统(OA管理系统源码+数据库+文档+PPT)
- Win11远程桌面连接怎么打开?Win11远程桌面连接的五种方法
- 学习使用js把两个对象合并成一个对象的方法Object.assign()
- Food Chem | in depth learning accurately predicts food categories and nutritional components based on ingredient statements
- 如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
- Mysql-数据丢失,分析binlog日志文件
- 什么是 CGI,什么是 IIS,什么是VPS「建议收藏」
- The most complete deployment of mongodb in history
- NanopiNEO使用开发过程记录
猜你喜欢
How do test / development programmers get promoted? From nothing, from thin to thick
EasyCVR视频广场点击播放时,主菜单高亮效果消失问题的修复
Continuous learning of Robotics (Automation) - 2022-
Storage of data
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
ABAP 動態內錶分組循環
英特尔与信步科技共同打造机器视觉开发套件,协力推动工业智能化转型
CUDA Programming
测试/开发程序员怎么升职?从无到有,从薄变厚.......
Video fusion cloud platform easycvr video Plaza left column list style optimization
随机推荐
这项15年前的「超前」技术设计,让CPU在AI推理中大放光彩
PHP 实现根据概率抽奖
Analysis on urban transportation ideas of 2022 Zhongqing cup C
Using thread class and runnable interface to realize the difference between multithreading
[multi threading exercise] write a multi threading example of the producer consumer model.
Redis源码学习(30),字典学习,dict.h
Simple implementation of AVL tree insertion and verification operations
Pyqt5 out of focus monitoring no operation timer
【刷题记录】2. 两数相加
Ssm+jsp realizes enterprise management system (OA management system source code + database + document +ppt)
Tflite model transformation and quantification
How to write a resume that shines in front of another interviewer [easy to understand]
2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
主设备号和次设备号均为0
Why does WordPress open so slowly?
Video fusion cloud platform easycvr video Plaza left column list style optimization
Unity3d can change colors and display samples in a building GL material
The first introduction of the most complete mongodb in history
DAB-DETR: DYNAMIC ANCHOR BOXES ARE BETTER QUERIES FOR DETR翻译
Redis source code learning (30), dictionary learning, dict.h