原创声明
本文系作者辛苦码字所得,欢迎分享和转载,但请在明显位置注明作者的如下信息:
笔名:来碗鸡蛋面
简书主页:https://www.jianshu.com/u/4876275b5a73
邮箱:job_tom@foxmail.com
CSDN ID:tom_wong666
一,npm安装
npm install --save axios vue-axios
二,main.js设置
import axios from 'axios'
Vue.prototype.$http = axios
三,组件内使用
this.$http.post('http://127.0.0.1/main.php?cid=1')
.then(res=>{
//验证是否成功获取数据
console.log(res);
}).catch(error=>{
//数据错误时的异常处理
console.log(error);
})
网友评论