daiwei 1 год назад
Родитель
Сommit
6daa180de9
1 измененных файлов с 5 добавлено и 6 удалено
  1. 5 6
      packages/runtime-core/src/components/Teleport.ts

+ 5 - 6
packages/runtime-core/src/components/Teleport.ts

@@ -308,12 +308,6 @@ export const TeleportImpl = {
       target,
       props,
     } = vnode
-
-    if (target) {
-      hostRemove(targetStart!)
-      hostRemove(targetAnchor!)
-    }
-
     // an unmounted teleport should always unmount its children whether it's disabled or not
     doRemove && hostRemove(anchor!)
 
@@ -321,6 +315,11 @@ export const TeleportImpl = {
     const disabled = isTeleportDisabled(props)
     if (!disabled && !target) return
 
+    if (target) {
+      hostRemove(targetStart!)
+      hostRemove(targetAnchor!)
+    }
+
     if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
       const shouldRemove = doRemove || !disabled
       for (let i = 0; i < (children as VNode[]).length; i++) {