Vue-axios基础
可以直接使用代码引用
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
分为post和get请求
post请求
axios.post(api,{参数对象}).then{function(response){},function(err){}}
以官方文档为例:
axios.post('/user', { firstName: 'Fred', lastName: 'Flintstone' }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); });
get请求
axios.get(api?key=数值&key2=数值$...).then{function(response){},function(err){}}
以官方文档为例:
// 为给定 ID 的 user 创建请求 axios.get('/user?ID=12345') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); // 上面的请求也可以这样做 axios.get('/user', { params: { ID: 12345 } }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); });

浙公网安备 33010602011771号