Loading... axios请求中的回调函数不能用this关键字,因为this指的是窗口,不是vue实例。 //发送GET方式请求 axios.get('xxx/login?a=1').then(res=>{}) //发送POST方式请求 axios.post('api/login/user',{uernamme:"张三",password:123}).then(res=>{}) ### axios并发请求 `并发请求`: 将多个请求在同一时刻发送到后端服务接口,最后再集中处理每个请求的响应结果 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) { // 两个请求现在都执行完成 })); axios拦截器 作用:用来将axios中的共有参数,响应公共处理交给拦截器处理,减少axios请求数据时的冗余 最后修改:2022 年 10 月 20 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 0 如果觉得我的文章对你有用,请随意赞赏