diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 3ed42ed0b55..5b094a0d611 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -806,7 +806,7 @@ export function setupComponent( const { props, children } = instance.vnode const isStateful = isStatefulComponent(instance) initProps(instance, props, isStateful, isSSR) - initSlots(instance, children, optimized) + initSlots(instance, children, optimized || isSSR) const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) diff --git a/packages/server-renderer/__tests__/ssrSlot.spec.ts b/packages/server-renderer/__tests__/ssrSlot.spec.ts index 02872274ab6..4cc7fd97ef2 100644 --- a/packages/server-renderer/__tests__/ssrSlot.spec.ts +++ b/packages/server-renderer/__tests__/ssrSlot.spec.ts @@ -1,4 +1,4 @@ -import { createApp } from 'vue' +import { createApp, defineAsyncComponent, h } from 'vue' import { renderToString } from '../src/renderToString' const components = { @@ -154,6 +154,38 @@ describe('ssr: slot', () => { ).toBe(`
1
2