首页 > 解决方案 > jquery ajaxComplete 在 axios 中的等价物

问题描述

开始学习 axios,我很喜欢它!

快速的问题,找不到答案,也许没有。

在 jQuery ajax 中有一个名为 ajaxComplete 的方法,我在徘徊,如果在 axios 中有一个等价物?

标签: javascriptjqueryajaxaxios

解决方案


axios 使用承诺。您可以使用

axios.get(url,[options]).then(res=>{
/* hande it here */
})

如果您没有基本知识,请查看 js 承诺如何工作https://web.dev/promises/

对于全局处理 axios 事件,这可能会有所帮助https://auralinna.blog/post/2019/global-http-request-and-response-handling-with-the-axios-interceptor/


推荐阅读