当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- [note] error while loading pyv8 binary: exit code 1 solution
- How to deploy Gantt chart quickly and correctly
- 2020-08-15: under what circumstances should data tasks be optimized?
- [original] the impact of arm platform memory and cache on the real-time performance of xenomai
- Idea activation to 2089 failure
- Application of UHF RFID medical blood management system
- Mate 40 series launch with Huawei sports health service to bring healthy digital life
- How does LeadTools detect, read and write barcodes
- 把 4个消息队列都拉到一个群里后,他们吵起来了
- 条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
猜你喜欢
课堂练习
Exclusive interview with alicloud database of | 2020 PostgreSQL Asia Conference: Wang Xu
11. Service update
yum [Errno 256] No more mirrors to try 解决方法
三步轻松理解Kerberos协议
CI / CD of gitlab continuous integrated development environment
Stm32f030c6t6 compatible to replace mm32spin05pf
Getting started with varhart xgantt
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
随机推荐
Is blazor ready to serve the enterprise?
抽絲剝繭——門面和調停者設計模式
Do you really know how to use search engines?
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
如何使用甘特图图层和筛选器
2020-08-19: what mechanism does TCP ensure reliability?
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
Jenkins入门(二)声明式流水线Jenkins Pipeline
【原創】ARM平臺記憶體和cache對xenomai實時性的影響
【笔记】Error while loading PyV8 binary: exit code 1解决方法
Shanghai Pudong Development Bank, which frequently receives penalty tickets, has been cheated by hundreds of millions of yuan in loans, and lacks of internal control?
How to add modules to nginx image?
Exclusive interview with alicloud database of | 2020 PostgreSQL Asia Conference: Wang Xu
11.Service更新
Using JSON webtoken (JWT) to generate token in nodejs
yum [Errno 256] No more mirrors to try 解决方法
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
August 14, 2020: what are the execution engines for data tasks?
Python 3 operates the Jenkins module API
[doodling the footprints of Internet of things] Introduction to Internet of things