@opensig/opendesign
Version:
<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>
42 lines (41 loc) • 965 B
JavaScript
import { isRef, watch, onMounted, h, render } from "vue";
import _sfc_main from "./OLoading.vue.mjs";
const initLoading = (opt, el) => {
const vnode = h(_sfc_main, Object.assign(opt || {}, { wrapper: el }));
if (el) {
render(vnode, el);
}
return vnode.component;
};
const useLoading = (opt, wrap = "body") => {
let instance = null;
if (isRef(wrap)) {
watch(
() => wrap.value,
(el) => {
instance = initLoading(opt, el);
},
{
immediate: true
}
);
} else if (wrap.nodeType === 1) {
instance = initLoading(opt, wrap);
} else if (typeof wrap === "string") {
onMounted(() => {
const el = document.querySelector(wrap);
if (el) {
instance = initLoading(opt, el);
}
});
}
return {
toggle(show) {
var _a;
(_a = instance == null ? void 0 : instance.exposed) == null ? void 0 : _a.toggle(show);
}
};
};
export {
useLoading as default
};