How to achieve loading effect in vue axios interceptor?

to achieve the effect, the loading icon is displayed on the page when pending is requested:

clipboard.png

clipboard.png

preliminary experiment, hoping to have a public vuex, and then merge the store of each single page with this common store,axios interceptor setting axiosing=true every time the request is initiated, and axiosing=false

after the request ends.

problem, but what about the public vuex? Or is there any other way to achieve this effect? Thank you

Mar.02,2021

vuex are all public, but private ones will not be used.


axios interceptor do it: in request processing axios.interceptors.request, open, in axios.interceptors.response response processing close, deals with requested pages, and static pages do not need to be a loading.

Menu