Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /** * @author SoldierAb */ import LoadingComp from "./src/Loading.vue"; let LoadingInstance = null; const Loading = (Vue, opts) => { if (!opts) opts = { background: "rgba(0,0,0,0.6)", color: "#4b9cdb" }; let { background, color } = opts; if (!background) background = "rgba(0,0,0,0.6)"; if (!color) color = "#4b9cdb"; Vue.prototype.$loading = (showLoading, callback) => { if (!LoadingInstance) { const LoadingTpl = Vue.extend(LoadingComp); LoadingInstance = new LoadingTpl(); LoadingInstance.background = background; LoadingInstance.color = color; const tpl = LoadingInstance.$mount().$el; document.body.appendChild(tpl); } LoadingInstance.show = showLoading; if (!callback) callback = new Function(); callback(); }; ["show", "hide"].forEach(item => { return (Vue.prototype.$loading[`${item}`] = callback => Vue.prototype.$loading(item === "show", callback)); }); }; export default Loading; |