软件外包是什么意思衡阳网站优化公司
1.安装axios:npm install axios,等待安装完毕即可
2.引用axios:在需要使用的页面中引用
import axios from 'axios'即可
get和post大同小异,一个是跟在url后面一个是跟在请求体里的
axios({method:"post/get",url: "", // 接口params: {// 参数name: xxx,},}).then(function (res) {console.log(res); // 成功回调}).catch(function (err) {console.log(err); // 失败回调});
method:创建请求时使用的方法
url:请求的服务器地址
header:即将被发送的自定义请求头
data:请求接口所需要传递的参数
params:即将与请求一起发送的 URL 参数
then(function(succ) {}):成功时返回的数据
catch(function(err){}):失败时返回的信息