ajax axios vue

vue中axios和ajax区别是什么

清风
3638
2021-03-15 08:00:46
栏目: 编程语言

vue中axios和ajax区别是什么

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);

}

});

0
看了该问题的人还看了