axios({
method:请求方式,
url:请求地址,
data:设置请求的数据(post和put的数据),
params:设置请求的参数(get请求和delete请求),
headers:{'token':'ssws34fdshrw'},#请求头中的数据从这里传输
}).then(function(res){
console.log(res) res拿成功的结果
#要拿到后端的数据,需要
res.data //因为axios对结果封装了一层
}).catch(function(error){
console.log(error) 拿到错误的结果
})
vue中使用axios发送请求
最新推荐文章于 2023-12-21 13:18:04 发布