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);
// 请求失败后,获取的相应内容
})

 

posted @ 2021-01-06 09:54  Feng_fu  阅读(45)  评论(0编辑  收藏  举报