第一步: 安装 sudo cnpm install axios --save
第二步: 在main.js里面引用 (类似于模块)
import Axios from 'axios'
Vue.prototype.$http=Axios
![](https://img.haomeiwen.com/i11689093/90bab60c4c379828.png)
第三步:在build文件夹下,新建server.js,搭建后台环境,提供接口,供vue访问(主要用了两种方式,1,直接创建了一个对象,2,读取一个json文件)
![](https://img.haomeiwen.com/i11689093/b806dc35009e8f97.png)
第四步:在config / index.js中,设置代理接口
![](https://img.haomeiwen.com/i11689093/8c8ce568b6d4c78e.png)
第五步:vue发送请求
![](https://img.haomeiwen.com/i11689093/3f71e0cc822e0d9a.png)
第一步: 安装 sudo cnpm install axios --save
第二步: 在main.js里面引用 (类似于模块)
import Axios from 'axios'
Vue.prototype.$http=Axios
第三步:在build文件夹下,新建server.js,搭建后台环境,提供接口,供vue访问(主要用了两种方式,1,直接创建了一个对象,2,读取一个json文件)
第四步:在config / index.js中,设置代理接口
第五步:vue发送请求
本文标题:Vue--Axios网络请求
本文链接:https://www.haomeiwen.com/subject/qytejftx.html
网友评论