当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王旭
- ImageMagick - 添加水印
- 9.集群之间服务通信 RoutingMesh
- Solution to st link USB communication error in stlink Download
- Design pattern of facade and mediator
- How to deploy Gantt chart quickly and correctly
- k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
- 2020-08-17: how to solve data skew in detail?
- Nonvolatile MRAM memory used in all levels of cache
- 小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
猜你喜欢

STlink下载出现st-link usb communication error解决方法

Idea activation to 2089 failure

三步轻松理解Kerberos协议

Insomnia all night

Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification

The use of Xunwei imx6 development board device tree kernel menuconfig

VARCHART XGantt如何在日历上表示工作日

Stm32f030k6t6 compatible replacement smart mm32f031k6t6

傲視Kubernetes(一):Kubernetes簡介

k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
随机推荐
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
In 2020, how can wechat seal numbers be quickly lifted?
如何创建交互式内核密度图表
.NETCore3.1+Vue.js打造的低代码工作流引擎
Gantt chart grouping activities tutorial
Composition of MRAM cache
Solution to st link USB communication error in stlink Download
心理咨询app开发所具备的优点与功能
REM: the solution of PC and mobile
微服務 - 如何進行服務限流和熔斷
2020-08-15: under what circumstances should data tasks be optimized?
9.集群之间服务通信 RoutingMesh
win7如何快速打cmd并到达所要的目录
The advantages and functions of psychological counseling app
VARCHART XGantt入门教程
2020-08-19: what mechanism does TCP ensure reliability?
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
Mobile pixel adaptation scheme
The use of Xunwei imx6 development board device tree kernel menuconfig