mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): include missing <NuxtPage>
component props (#9204)
Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
parent
a4e0a64f33
commit
4f2bfbe5c0
@ -40,7 +40,7 @@ export default defineComponent({
|
||||
default: (routeProps: RouterViewSlotProps) => {
|
||||
if (!routeProps.Component) { return }
|
||||
|
||||
const key = generateRouteKey(props.pageKey, routeProps)
|
||||
const key = generateRouteKey(routeProps, props.pageKey)
|
||||
const done = nuxtApp.deferHydration()
|
||||
|
||||
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
||||
@ -62,7 +62,9 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
}) as DefineComponent<{
|
||||
name?: string,
|
||||
name?: string
|
||||
transition?: boolean | TransitionProps
|
||||
keepalive?: boolean | KeepAliveProps
|
||||
route?: RouteLocationNormalized
|
||||
pageKey?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
||||
[key: string]: any
|
||||
|
@ -12,7 +12,7 @@ const interpolatePath = (route: RouteLocationNormalizedLoaded, match: RouteLocat
|
||||
.replace(/:\w+/g, r => route.params[r.slice(1)]?.toString() || '')
|
||||
}
|
||||
|
||||
export const generateRouteKey = (override: string | ((route: RouteLocationNormalizedLoaded) => string), routeProps: RouterViewSlotProps) => {
|
||||
export const generateRouteKey = (routeProps: RouterViewSlotProps, override?: string | ((route: RouteLocationNormalizedLoaded) => string)) => {
|
||||
const matchedRoute = routeProps.route.matched.find(m => m.components?.default === routeProps.Component.type)
|
||||
const source = override ?? matchedRoute?.meta.key ?? (matchedRoute && interpolatePath(routeProps.route, matchedRoute))
|
||||
return typeof source === 'function' ? source(routeProps.route) : source
|
||||
|
@ -362,7 +362,7 @@ describe('pages:generateRouteKey', () => {
|
||||
|
||||
for (const test of tests) {
|
||||
it(test.description, () => {
|
||||
expect(generateRouteKey(test.override, test.route)).to.deep.equal(test.output)
|
||||
expect(generateRouteKey(test.route, test.override)).to.deep.equal(test.output)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user