当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- .NETCore3.1+Vue.js打造的低代码工作流引擎
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
- 7. Swarm builds clusters
- Mobile pixel adaptation scheme
- How does varhart xgantt represent working days on a calendar
- Nanjing logo design and production, guide VI system design
- Win7 AppCrash (solution)
- 7.Swarm搭建集群
- Do you really know how to use search engines?
- 谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
猜你喜欢

图像处理工具包ImagXpress使用教程,如何查看事件

python3操作gitlab

Image processing toolkit imagexpresshow to view events

南京标识标牌设计制作,导视VI系统设计

使用LWA和Lync模拟外部测试无边缘单前端环境

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?

FreeSWITCH视频会议“标准”解决方案

Using JSON webtoken (JWT) to generate token in nodejs

快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!

Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
随机推荐
Stm32f030c6t6 compatible to replace mm32spin05pf
Knowledge competition of garbage classification
HMS Core推送服务,助力电商App开展精细化运营
Composition of MRAM cache
9. Routingmesh service communication between clusters
Python 3 operates the Jenkins module API
Git SSH bad permissions
August 18, 2020: introduce Mr process?
垃圾分类知识竞赛
9.集群之间服务通信 RoutingMesh
插件Bilibili新版0.5.5
Mate 40 series launch with Huawei sports health service to bring healthy digital life
如何使用甘特图图层和筛选器
2020-11-06:go中,谈一下调度器。
.NETCore3.1+ Vue.js Low code workflow engine
In 2020, how can wechat seal numbers be quickly lifted?
三步轻松理解Kerberos协议
Yum [errno 256] no more mirrors to try solution
Exclusive interview with Yue Caibo
Blazor 準備好為企業服務了嗎?