feat(nuxt): expose default slot from <NuxtPage> (#27050)

This commit is contained in:
Alex Liu 2024-05-03 20:58:18 +08:00 committed by GitHub
parent 589b4037c1
commit 4779f5906f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
import { Suspense, Transition, defineComponent, h, inject, nextTick, ref, watch } from 'vue'
import { Fragment, Suspense, Transition, defineComponent, h, inject, nextTick, ref, watch } from 'vue'
import type { KeepAliveProps, TransitionProps, VNode } from 'vue'
import { RouterView } from '#vue-router'
import { defu } from 'defu'
@ -37,7 +37,7 @@ export default defineComponent({
default: null,
},
},
setup (props, { attrs, expose }) {
setup (props, { attrs, slots, expose }) {
const nuxtApp = useNuxtApp()
const pageRef = ref()
const forkRoute = inject(PageRouteSymbol, null)
@ -120,7 +120,7 @@ export default defineComponent({
default: () => {
const providerVNode = h(RouteProvider, {
key: key || undefined,
vnode: routeProps.Component,
vnode: slots.default ? h(Fragment, undefined, slots.default(routeProps)) : routeProps.Component,
route: routeProps.route,
renderKey: key || undefined,
trackRootNodes: hasTransition,