mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +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) => {
|
default: (routeProps: RouterViewSlotProps) => {
|
||||||
if (!routeProps.Component) { return }
|
if (!routeProps.Component) { return }
|
||||||
|
|
||||||
const key = generateRouteKey(props.pageKey, routeProps)
|
const key = generateRouteKey(routeProps, props.pageKey)
|
||||||
const done = nuxtApp.deferHydration()
|
const done = nuxtApp.deferHydration()
|
||||||
|
|
||||||
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
||||||
@ -62,7 +62,9 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) as DefineComponent<{
|
}) as DefineComponent<{
|
||||||
name?: string,
|
name?: string
|
||||||
|
transition?: boolean | TransitionProps
|
||||||
|
keepalive?: boolean | KeepAliveProps
|
||||||
route?: RouteLocationNormalized
|
route?: RouteLocationNormalized
|
||||||
pageKey?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
pageKey?: string | ((route: RouteLocationNormalizedLoaded) => string)
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
|
@ -12,7 +12,7 @@ const interpolatePath = (route: RouteLocationNormalizedLoaded, match: RouteLocat
|
|||||||
.replace(/:\w+/g, r => route.params[r.slice(1)]?.toString() || '')
|
.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 matchedRoute = routeProps.route.matched.find(m => m.components?.default === routeProps.Component.type)
|
||||||
const source = override ?? matchedRoute?.meta.key ?? (matchedRoute && interpolatePath(routeProps.route, matchedRoute))
|
const source = override ?? matchedRoute?.meta.key ?? (matchedRoute && interpolatePath(routeProps.route, matchedRoute))
|
||||||
return typeof source === 'function' ? source(routeProps.route) : source
|
return typeof source === 'function' ? source(routeProps.route) : source
|
||||||
|
@ -362,7 +362,7 @@ describe('pages:generateRouteKey', () => {
|
|||||||
|
|
||||||
for (const test of tests) {
|
for (const test of tests) {
|
||||||
it(test.description, () => {
|
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