当前位置:网站首页>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
},
边栏推荐
- Do you choose pandas or SQL for the top 1 of data analysis in your mind?
- Collection of idea gradle Lombok errors
- Redis source code learning (31), dictionary learning, dict.c (1)
- Both primary and secondary equipment numbers are 0
- 杭州电 3711 Binary Number
- [multi threading exercise] write a multi threading example of the producer consumer model.
- PHP 实现根据概率抽奖
- [team learning] [34 issues] scratch (Level 2)
- True global ventures' newly established $146million follow-up fund was closed, of which the general partner subscribed $62million to invest in Web3 winners in the later stage
- Some common software related
猜你喜欢
2022中青杯C题城市交通思路分析
EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
案例大赏:英特尔携众多合作伙伴推动多领域AI产业创新发展
EasyCVR无法使用WebRTC进行播放,该如何解决?
[OA] excel document generator: openpyxl module
Mysql-数据丢失,分析binlog日志文件
各路行业大佬称赞的跨架构开发“神器”,你get同款了吗?
The most complete learning rate adjustment strategy in history LR_ scheduler
Five years of automated testing, and finally into the ByteDance, the annual salary of 30W is not out of reach
Antd Comment 递归循环评论
随机推荐
[written to the person who first published the paper] common problems in writing comprehensive scientific and Technological Papers
5年自动化测试,终于进字节跳动了,年薪30w其实也并非触不可及
Antd Comment 递归循环评论
Using thread class and runnable interface to realize the difference between multithreading
The JSON format of the international area code of the mobile phone number is obtained with PHP
ABAP Dynamic Inner table Group cycle
Analysis on urban transportation ideas of 2022 Zhongqing cup C
【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
POJ training plan 2253_ Frogger (shortest /floyd)
Continuous learning of Robotics (Automation) - 2022-
用CPU方案打破内存墙?学PayPal堆傲腾扩容量,漏查欺诈交易量可降至1/30
Ssm+jsp realizes the warehouse management system, and the interface is called an elegant interface
Storage of data
别样肉客联手德克士在全国部分门店推出别样汉堡
这项15年前的「超前」技术设计,让CPU在AI推理中大放光彩
各路行业大佬称赞的跨架构开发“神器”,你get同款了吗?
机器人(自动化)课程的持续学习-2022-
C # use Siemens S7 protocol to read and write PLC DB block
Redis source code learning (31), dictionary learning, dict.c (1)
DAB-DETR: DYNAMIC ANCHOR BOXES ARE BETTER QUERIES FOR DETR翻译