当前位置:网站首页>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
},边栏推荐
- 史上最全MongoDB之Mongo Shell使用
- 【编码字体系列】OpenDyslexic字体
- Easycvr cannot be played using webrtc. How to solve it?
- Mathematical analysis_ Notes_ Chapter 10: integral with parameters
- ABAP dynamic inner table grouping cycle
- 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
- CUDA Programming
- [untitled]
- Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
- Web service performance monitoring scheme
猜你喜欢

超越Postman,新一代国产调试工具Apifox,用起来够优雅

【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析

Food Chem | in depth learning accurately predicts food categories and nutritional components based on ingredient statements

Mongo shell, the most complete mongodb in history

Class constant pool and runtime constant pool

数学分析_笔记_第10章:含参变量积分

EasyCVR平台接入RTMP协议,接口调用提示获取录像错误该如何解决?

SSM+jsp实现仓库管理系统,界面那叫一个优雅

Opencv third party Library
![[on automation experience] the growth path of automated testing](/img/28/38d82cbdc7ed249d376fff264d1b5d.png)
[on automation experience] the growth path of automated testing
随机推荐
PHP implements lottery according to probability
UltraEdit-32 warm prompt: right association, cancel bak file [easy to understand]
Learn how to use js to merge two objects into one object assign()
Some thoughts on cross end development of kbone and applet
Implementation of map and set
Continuous learning of Robotics (Automation) - 2022-
2022 middle school Youth Cup mathematical modeling question B fertility policy research ideas under the background of open three children
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
Win11图片打不开怎么办?Win11无法打开图片的修复方法
史上最全MongoDB之部署篇
EasyCVR无法使用WebRTC进行播放,该如何解决?
史上最全MongoDB之Mongo Shell使用
Win11控制面板快捷键 Win11打开控制面板的多种方法
史上最全MongoDB之安全认证
史上最全MongoDB之初识篇
UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
CUDA Programming
2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
Redis源码学习(30),字典学习,dict.h
用头像模仿天狗食月