vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
54 lines (53 loc) • 1.14 kB
JavaScript
import { createVNode as d, render as u } from "vue";
import a from "./index.vue.mjs";
const t = /* @__PURE__ */ new WeakMap(), m = (e) => {
if (!e)
return document.body;
if (typeof e == "string") {
const n = document.querySelector(e);
return n && n instanceof HTMLElement ? n : document.body;
}
return e instanceof HTMLElement ? e : document.body;
}, o = (e) => {
const n = m(e);
if (t.has(n))
return t.get(n);
const r = document.createElement("div");
n.appendChild(r);
const c = d(a);
u(c, r);
const s = c.component.exposed;
t.set(n, s);
const i = new MutationObserver(() => {
document.body.contains(n) || (t.delete(n), i.disconnect());
});
return i.observe(document.body, { childList: !0, subtree: !0 }), s;
}, b = {
/**
* 开始加载
*
* @param selector string | HTMLElement
*/
start(e) {
o(e).start();
},
/**
* 加载完成
*
* @param selector string | HTMLElement
*/
finish(e) {
o(e).finish();
},
/**
* 加载错误
*
* @param selector string | HTMLElement
*/
error(e) {
o(e).error();
}
};
export {
b as _LoadingBar
};