diff --git a/src/ui/components/FaDrawer/index.ts b/src/ui/components/FaDrawer/index.ts index 25f4281a..c41e7c91 100644 --- a/src/ui/components/FaDrawer/index.ts +++ b/src/ui/components/FaDrawer/index.ts @@ -103,6 +103,19 @@ export function useFaDrawer() { // 挂载到当前实例 instance?.proxy?.$el?.appendChild(container) + // 监听组件卸载,自动清理 + if (instance) { + onUnmounted(() => { + if (vnode) { + render(null, container) + vnode = null + } + if (container.parentNode) { + container.parentNode.removeChild(container) + } + }) + } + const open = () => { visible.value = true } diff --git a/src/ui/components/FaModal/index.ts b/src/ui/components/FaModal/index.ts index d418a560..44154da2 100644 --- a/src/ui/components/FaModal/index.ts +++ b/src/ui/components/FaModal/index.ts @@ -111,6 +111,19 @@ export function useFaModal() { // 挂载到当前实例 instance?.proxy?.$el?.appendChild(container) + // 监听组件卸载,自动清理 + if (instance) { + onUnmounted(() => { + if (vnode) { + render(null, container) + vnode = null + } + if (container.parentNode) { + container.parentNode.removeChild(container) + } + }) + } + const open = () => { visible.value = true }