From efc54f49eff214e6530d5de6689b7eb3e4c9ffe8 Mon Sep 17 00:00:00 2001 From: Hooray <304327508@qq.com> Date: Wed, 6 Aug 2025 18:06:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20`useFaModal`=20=E5=92=8C=20`useFaDrawer?= =?UTF-8?q?`=20=E9=A1=B5=E9=9D=A2=E5=8D=B8=E8=BD=BD=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/components/FaDrawer/index.ts | 13 +++++++++++++ src/ui/components/FaModal/index.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+) 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 }