axios使用
详细方式参考
- https://www.npmjs.com/package/axios
- cnd方式引入 (https://www.bootcdn.cn/axios/)
-
<script src="https://cdn.bootcss.com/axios/0.19.2/axios.min.js"></script>
- 更多例子 https://gitee.com/zhangsike/javaSummary/blob/master/docs/vue/axios%E4%BD%BF%E7%94%A8.md
get请求
方式一
axios.get('/user?ID=12345') .then(function (response) { // handle success console.log("success:"+response.status+","+JSON.stringify(response.data)); }) .catch(function (error) { // handle error console.log(error); }) .finally(function () { // always executed }); // 方式二 axios.get('/user', { params: { ID: 12345 } }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) .finally(function () { // always executed });