axios 发送ajax请求

axios 发送ajax请求
1、安装
npm install axios --save
2、导入axios
import axios from 'axios'
3、在main.js中配置

Vue.prototype.$axios = axios
this.$axios

4、发送请求

this.$axios.get('url')
.then(function (response){
console.log(response);
// 请求成功后,获取的相应内容
})    
.catch(function (response){
console.log(response);
// 请求失败后,获取的相应内容
})
原文地址:https://www.cnblogs.com/fenglingfu/p/14239379.html