import { loadingText, messageDuration } from "@/settings";
import { Loading } from "element-ui";
const install = (Vue, opts = {}) => {
Vue.prototype.$baseColorfullLoading = (index, text, callback) => {
let loading;
if (!index) {
loading = Loading.service({
lock: true,
text: text || loadingText,
spinner: "dots-loader",
background: "hsla(0,0%,100%,.8)",
});
} else {
switch (index) {
case 1:
index = "dots";
break;
case 2:
index = "gauge";
break;
case 3:
index = "inner-circles";
break;
case 4:
index = "plus";
break;
}
loading = Loading.service({
lock: true,
text: text || loadingText,
spinner: index + "-loader",
background: "hsla(0,0%,100%,.8)",
target: document.querySelector('.app-main-container'),
});
}
if (callback) {
callback(loading);
} else {
setTimeout(() => {
loading.close();
}, messageDuration);
}
};
};
if (typeof window !== "undefined" && window.Vue) {
install(window.Vue);
}
export default install;
调用
this.$baseColorfullLoading(3)