当前位置:网站首页>Vue: Axios uses this pointer
Vue: Axios uses this pointer
2020-11-07 16:54:00 【osc_write】
Preface
stay vue in , There are three types of modules that request back-end interfaces :
- vue-resource
- axios
- fetch
We use axios To request the back-end interface .
install
Get into vue Project directory , perform :
npm install axios --save
Use
axios Supported by http The request method is as follows
- axios.request(config)
- axios.get(url[, config])
- axios.delete(url[, config])
- axios.head(url[, config])
- axios.options(url[, config])
- axios.post(url[, data[, config]])
- axios.put(url[, data[, config]])
- axios.patch(url[, data[, config]])
This article does not focus on axios Use , Here we have get For example , In the use of axios When the receiving interface returns , You need to use arrows => Symbols get the right this The pointer .
this.$axios
.get("/userInfo")
.then(
(response) =>
// handle success (this.userdata = response.data) )
.catch(function (error) { // handle error console.log(error);
})
.then(function () { // always executed
});
If you don't want to use the arrow function, you can use the variable to get this The pointer , However, it is suggested to use the above method .
.$axios
.get("/userInfo")
.then(
function(response){
)
.( (error) { console.log(error);
})
.then( () {
});
Blogger : Test makes money
motto : Focus on testing and Automation , Committed to improving R & D efficiency ; Complete the original accumulation through testing , Financial freedom through reading and managing money .
csdn:https://blog.csdn.net/ccgshigao
Blog Garden :https://www.cnblogs.com/qa-freeroad/
版权声明
本文为[osc_write]所创,转载请带上原文链接,感谢
边栏推荐
- 三步轻松理解Kerberos协议
- Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
- 把 4个消息队列都拉到一个群里后,他们吵起来了
- Solution to st link USB communication error in stlink Download
- 南京标志设计,logo设计公司
- How does LeadTools detect, read and write barcodes
- 大佬们如何在nginx镜像里面增加模块?
- WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
- How does varhart xgantt represent working days on a calendar
- 快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
猜你喜欢
Chinese sub forum of | 2020 PostgreSQL Asia Conference: Pan Juan
Insomnia all night
OpenCV計算機視覺學習(10)——影象變換(傅立葉變換,高通濾波,低通濾波)
Two dimensional code location and alarm system of Expressway
How does LeadTools detect, read and write barcodes
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Do you really know how to use search engines?
HMS core push service helps e-commerce app to carry out refined operation
Exclusive interview with Yue Caibo
随机推荐
ImageMagick - 添加水印
Design pattern of facade and mediator
Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
STlink下载出现st-link usb communication error解决方法
9.集群之间服务通信 RoutingMesh
.NETCore3.1+Vue.js打造的低代码工作流引擎
把 4个消息队列都拉到一个群里后,他们吵起来了
Git SSH bad permissions
pc端与移动端适配解决方案之rem
甘特图对活动进行分组教程
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
git 提交规范
Classroom exercises
Gantt chart grouping activities tutorial
Design of NAND flash interface control
使用LWA和Lync模拟外部测试无边缘单前端环境
Talk about sharing before paying
And how to solve the conflict between pop-up menu and pop-up menu
Three steps to understand Kerberos Protocol easily
Stm32f030f4p6 compatible with smart micro mm32f031f4p6