This article shares with you the concept and usage of Axios in vue.js. It has a certain reference value. Friends in need can refer to it
1. What is Axios
https://www.kancloud.cn/yunye/axios/234845This is the official Chinese document, you can take a look
Axios is a promise-based HTTP library that can be used in browsers and node.js. Like ajax, it is used to interact with the background, but there are differences between the two.
The following is from Zhihu A paragraph:
axios is an encapsulation of ajax technology through promise, just like jQuery implements ajax encapsulation.
In simple terms: Ajax technology realizes partial data refresh of web pages, and axios realizes the encapsulation of ajax.
Axios is ajax Ajax is more than axios, This passage can well explain the relationship between the two
juuery Ajax is mainly for mvc programming , it is increasingly unable to keep up with the current rhythm, and juuery is too big. It is not worth the gain to introduce jquery just for ajax. With the rise of more and more frameworks, the road of jquery is getting narrower and narrower
axios has the following characteristics
##
Support Promise API # Client
Support to prevent csrf
##Q The interface of concurrent requests (important, it is convenient for many operations) ## This is relatively small compared to Ajax, Axios is smaller
## This
Having said so much, everyone should understand the difference between the two, so let me introduce to you the specific usage
同事支持多个请求 如何安装呢 使用 npm : 使用 bower: 使用 cdn:function getUserAccount() {
return axios.get('/user/12345');
}
function getUserPermissions() {
return axios.get('/user/12345/permissions');
}
axios.all([getUserAccount(), getUserPermissions()])
.then(axios.spread(function (acct, perms) {
// 两个请求现在都执行完成
}));
$ npm install axios
$ bower install axios
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
The above is the detailed content of The concept and usage of Axios in vue.js. For more information, please follow other related articles on the PHP Chinese website!