feat: useFaModal 和 useFaDrawer 页面卸载时自动清理

This commit is contained in:
Hooray
2025-08-06 18:06:40 +08:00
parent 0b9d11fcfa
commit efc54f49ef
2 changed files with 26 additions and 0 deletions
+13
View File
@@ -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
}
+13
View File
@@ -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
}