/** * 获取/创建浮层容器 */ import { injectValue } from "./inject-value"; const rootId = "tea-overlay-root"; let root: HTMLElement; export type AttachContainer = HTMLElement | (() => HTMLElement); export function getOverlayRoot(popupContainer?: AttachContainer) { if (popupContainer) { return injectValue(popupContainer)(); } if (typeof document === "object") { root = root || document.getElementById(rootId); if (!root) { root = document.createElement("div"); root.id = rootId; document.body.appendChild(root); } } return root; }