vue使用axios的几种方式
发布日期:2021-10-12 17:51:34 浏览次数:3 分类:技术文章

本文共 726 字,大约阅读时间需要 2 分钟。

方式一:将axios改写为vue的原型属性

1、安装axios

npm install vue-axios --save

2、main.js文件

import axios from 'axios'Vue.prototype.$http = axios

3、.vue文件

test(){        var testUrl='http://localhost:8088/activiti/doneTask';        this.$http.get(testUrl).then(function(response){            alert(response.data);        }).catch(function (response) {          alert("error");        })},

方式二:结合 vue-axios使用

1、安装vue-axios

npm install vue-axios --save

2、main.js文件

import axios from 'axios'Vue.prototype.$http = axiosimport VueAxios from 'vue-axios'

3、.vue文件

test(){        var testUrl='http://localhost:8088/activiti/doneTask';       this.axios.get(testUrl).then((response) =>{		alert(response.data())	}).catch((response) =>{		alert("error");	})},

转载地址:https://blog.csdn.net/qq_39387856/article/details/84316728 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:vue使用axios跨域访问实现及问题分析
下一篇:org.activiti.engine.ActivitiIllegalArgumentException: unknown type 'XXX' xxxx

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月09日 12时15分06秒