当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Benefits and functions of auto maintenance app development
- 11. Service update
- 垃圾分类知识竞赛
- 谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
- 失眠一个整晚上
- 条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
- Do you really know how to use search engines?
- Plug in bilibilibili new version 0.5.5
- 聊聊先享後付
- Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
猜你喜欢
JS string - string string object method
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
Classroom exercises
2020-08-17: how to solve data skew in detail?
Win7 how to quickly type CMD and get to the required directory
How to use Gantt chart layers and filters
如何解决谷歌Chrome浏览器空白页的问题
Mobile pixel adaptation scheme
confd
Application of UHF RFID medical blood management system
随机推荐
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
Chinese sub forum of | 2020 PostgreSQL Asia Conference: Pan Juan
How to add modules to nginx image?
How does LeadTools detect, read and write barcodes
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
Insomnia all night
RFID fixed assets management system for fire equipment
JS string - string string object method
C# 枚举权限 |和||,&和&&的区别
win7如何快速打cmd并到达所要的目录
.NETCore3.1+Vue.js打造的低代码工作流引擎
Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
Win7 AppCrash (solution)
python3操作Jenkins模块api
idea 激活到 2089 失效
ImageMagick - 添加水印
Knowledge competition of garbage classification
[doodling the footprints of Internet of things] Introduction to Internet of things