diff --git a/packages/nuxt/src/pages/runtime/page.ts b/packages/nuxt/src/pages/runtime/page.ts index 55428b7873..a42c77c37a 100644 --- a/packages/nuxt/src/pages/runtime/page.ts +++ b/packages/nuxt/src/pages/runtime/page.ts @@ -1,5 +1,5 @@ -import { defineComponent, h, inject, provide, Suspense, Transition } from 'vue' -import { RouteLocationNormalizedLoaded, RouterView } from 'vue-router' +import { DefineComponent, defineComponent, h, inject, provide, Suspense, Transition } from 'vue' +import { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouterView } from 'vue-router' import { generateRouteKey, RouterViewSlotProps, wrapInKeepAlive } from './utils' import { useNuxtApp } from '#app' @@ -9,20 +9,27 @@ const isNestedKey = Symbol('isNested') export default defineComponent({ name: 'NuxtPage', + inheritAttrs: false, props: { + name: { + type: String + }, + route: { + type: Object as () => RouteLocationNormalized + }, pageKey: { type: [Function, String] as unknown as () => string | ((route: RouteLocationNormalizedLoaded) => string), default: null } }, - setup (props) { + setup (props, { attrs }) { const nuxtApp = useNuxtApp() const isNested = inject(isNestedKey, false) provide(isNestedKey, true) return () => { - return h(RouterView, {}, { + return h(RouterView, { name: props.name, route: props.route, ...attrs }, { default: (routeProps: RouterViewSlotProps) => routeProps.Component && _wrapIf(Transition, routeProps.route.meta.pageTransition ?? defaultPageTransition, wrapInKeepAlive(routeProps.route.meta.keepalive, @@ -37,6 +44,11 @@ export default defineComponent({ }) } } -}) +}) as DefineComponent<{ + name?: string, + route?: RouteLocationNormalized + pageKey?: string | ((route: RouteLocationNormalizedLoaded) => string) + [key: string]: any +}> const defaultPageTransition = { name: 'page', mode: 'out-in' }