当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
- yum [Errno 256] No more mirrors to try 解决方法
- 嘉宾介绍|2020 PostgreSQL亚洲大会中文分论坛:潘娟
- [graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
- Win7 AppCrash (solution)
- 把 4个消息队列都拉到一个群里后,他们吵起来了
- Configuration of AP hotspot on xunwei-imx6ull development board
- August 14, 2020: what are the execution engines for data tasks?
- Logo design company, Nanjing
猜你喜欢

谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
![Yum [errno 256] no more mirrors to try solution](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Yum [errno 256] no more mirrors to try solution

甘特图对活动进行分组教程

RFID fixed assets management system for fire equipment
![yum [Errno 256] No more mirrors to try 解决方法](/img/3b/00bc81122d330c9d59909994e61027.jpg)
yum [Errno 256] No more mirrors to try 解决方法

Nonvolatile MRAM memory used in all levels of cache

傲視Kubernetes(一):Kubernetes簡介

Classroom exercises

关于DevOps的七大误解,99%的人都曾中过招!

cubemx做stm32 USB开发
随机推荐
FreeSWITCH视频会议“标准”解决方案
Classroom exercises
Two dimensional code location and alarm system of Expressway
Git submission specification
课堂练习
Using rabbitmq to implement distributed transaction
Using JSON webtoken (JWT) to generate token in nodejs
jenkins pipline stage 设置超时
How to add modules to nginx image?
谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
.NETCore3.1+Vue.js打造的低代码工作流引擎
傲視Kubernetes(一):Kubernetes簡介
CI / CD of gitlab continuous integrated development environment
Image processing toolkit imagexpresshow to view events
Git SSH bad permissions
Talk about sharing before paying
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
聊聊先享後付
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
三步轻松理解Kerberos协议