当前位置:网站首页>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-11-06:go中,谈一下调度器。
9.集群之间服务通信 RoutingMesh
VARCHART XGantt入门教程
pc端与移动端适配解决方案之rem
How to use Gantt chart layers and filters
Win7 how to quickly type CMD and get to the required directory
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
New features of vue3
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
【笔记】Error while loading PyV8 binary: exit code 1解决方法
随机推荐
C語言重點——指標篇(一文讓你完全搞懂指標)| 從記憶體理解指標 | 指標完全解析
[doodling the footprints of Internet of things] Introduction to Internet of things
Talk about sharing before paying
In 2020, how can wechat seal numbers be quickly lifted?
jenkins pipline stage 设置超时
【原創】ARM平臺記憶體和cache對xenomai實時性的影響
如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
Composition of MRAM cache
Design of NAND flash interface control
REM: the solution of PC and mobile
The use of Xunwei imx6 development board device tree kernel menuconfig
Python3 operating gitlab
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
Chinese sub forum of | 2020 PostgreSQL Asia Conference: Pan Juan
Come on in! Take a few minutes to see how reentrantreadwritelock works!
Win7 how to quickly type CMD and get to the required directory
FreeSWITCH视频会议“标准”解决方案
抽絲剝繭——門面和調停者設計模式
谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications