How to output a vue component in the interceptor of axios?

I wrote a loading component, and then configured axios to intercept requests and responses.
wants to appear loading,
on the request and make the loading component disappear. I don"t know how to write it.

clipboard.png

loading

clipboard.png

then remove loading after getting the request

Mar.02,2021
Register a loading state in

vuex, and change the loading state in the axios interceptor


Why do you have to output a component? You can control the v-show state of the loading component in different function hooks


/ / add request interceptor
axios.interceptors.request.use (function (config) {

// 
return config;

}, function (error) {

// 
return Promise.reject(error);

});

/ / add response interceptor
axios.interceptors.response.use (function (response) {

// 
return response;

}, function (error) {

// 
return Promise.reject(error);

});

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5068d-656c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5068d-656c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?