Linux 拨号vps windows公众号手机端

vue中axios和ajax区别是什么

lewis 6年前 (2019-04-11) 阅读数 12 #程序编程
文章标签 ajaxaxiosvue

vue中axios和ajax区别是:

1.axios是通过promise实现对ajax技术的一种封装,而ajax则是实现了网页的局部数据刷新。

2.axios可以说是ajax,而ajax不止是axios。

3.用法相同,但个别参数不同。

axios用法:

axios({

url: '/getName',

method: 'get',

responseType: 'json', // 默认的

data: {

name:'tom'

}

}).then(function (response) {

console.log(response);

console.log(response.data);

}).catch(function (error) {

console.log(error);

});

ajax的用法:

$.ajax({

url: '/getName',

type: 'get',

dataType: 'json',

data: {

name:'tom'

},

success: function (response) {

console.log(response);

}

});

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门