Several ways for vue to request data from the background during the development process
The first is our traditional ajax
, the second is jquery-ajxax,
and the third is our commonly used axios
First of all, the traditional ajax is that the configuration mode is relatively chaotic, which affects the development efficiency
The second is jquery-ajax, which is also very common in development, but only limited to our development framework is jquery, because we are using the vue framework, it has only 10,000 lines of code, and jquery is also
10,000 line of code, if we want to use jquery-ajax, then we must use this framework, the code is too redundant, it is not necessary
The third is our axios , which is a promise-based http library. Simply put, it is to add some promise code to axios.
Why use it, it has several advantages
第一种是可以用prmise api
第二种是具备响应拦截与请求拦截
第三种是可以取消请求,
第四种自动转换为json数据,
第五种是客户端支持xsrf攻击,