【问题标题】:How to stop loading on interceptor.r axios.interceptors.request in ionic vue?如何停止在 ionic vue 中的interceptor.r axios.interceptors.request 上加载?
【发布时间】:2021-02-09 19:51:10
【问题描述】:

我正在学习本教程。

https://www.djamware.com/post/5fc19e3e77862f22905c7f03/ionic-5-tutorial-oauth2-login-example-vue

在本教程中,他正在调用这个函数,该函数调用每个 axios 请求

mountRequestInterceptor() {
        this._requestInterceptor = axios.interceptors.request.use(async config => {
            console.log("show loading");
            const loading = await loadingController.create({
                message: 'Please wait...'
            });
            await loading.present();
           
                
           
            
            return config;
        });
        console.log(this._requestInterceptor,'sasdas')
    },

问题是加载在 axios 请求上开始但从未停止。

我希望它在请求成功时停止

【问题讨论】:

    标签: javascript vue.js ionic-framework axios


    【解决方案1】:

    我不确定您的代码有什么问题,但我看不出_interceptors.response 在哪里。

    我做了同样的功能来拥有一个全局加载器。 我在_interceptors.request 启动它并在_interceptors.response 关闭它。

    也许这个博客会对你有所帮助

    https://codeburst.io/global-loader-component-using-vue-js-and-axios-interceptors-3880a136a4ac

    【讨论】:

      猜你喜欢
      • 2018-02-27
      • 2018-10-07
      • 2018-07-18
      • 2018-10-29
      • 2012-01-24
      • 2012-03-28
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      相关资源
      最近更新 更多