diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index 5d41751285b..8fa272d2613 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -470,15 +470,17 @@ function getKeepAliveChild(vnode: VNode): VNode | undefined { const { shapeFlag, children } = vnode - if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) { - return (children as VNodeArrayChildren)[0] as VNode - } + if (children) { + if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) { + return (children as VNodeArrayChildren)[0] as VNode + } - if ( - shapeFlag & ShapeFlags.SLOTS_CHILDREN && - isFunction((children as any).default) - ) { - return (children as any).default() + if ( + shapeFlag & ShapeFlags.SLOTS_CHILDREN && + isFunction((children as any).default) + ) { + return (children as any).default() + } } }