How to call methods such as iview's message or spin in a separate js file

vue project, using iview"s UI
request.js is a simple encapsulation of axios
now you want to display a Loading mask before each network request
before using elementUI, you can write this directly in the js file

import { Loading } from "element-ui";
Loading.service(options);

so you don"t have to rely on vue files
but there seems to be no such method in iview
I don"t know if I didn"t find

.

does anyone have the same need to share the solution

Mar.03,2021

just add the loading component to the vue and control whether it is displayed or not in the js. Using vuex


since it is a vue project, it doesn't matter if you introduce loading and vue into requestjs on demand, just use it. Or you can trigger loading through vuex

.
Menu