UNPKG

uv-ui

Version:

基于vue3的移动端组件库

30 lines (29 loc) 868 B
import { watch as h, unref as d, getCurrentScope as m, onScopeDispose as A } from "vue"; function w(t) { return m() ? (A(t), !0) : !1; } function E(...t) { let i, r, n, f; if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([r, n, f] = t, i = typeof window < "u" ? window : void 0) : [i, r, n, f] = t, !i) return () => { }; Array.isArray(r) || (r = [r]), Array.isArray(n) || (n = [n]); const p = [], a = () => { p.forEach((e) => e()), p.length = 0; }, l = (e, o, s, u) => (e.addEventListener(o, s, u), () => e.removeEventListener(o, s, u)), y = h( () => [d(i), d(f)], ([e, o]) => { a(), e && p.push( ...r.flatMap((s) => n.map((u) => l(e, s, u, o))) ); }, { immediate: !0, flush: "post" } ), c = () => { y(), a(); }; return w(c), c; } export { w as tryOnScopeDispose, E as useEventListener };