fix(nuxt): defer adding route path to preloaded record (#18862)

This commit is contained in:
Alex Liu 2023-02-07 22:01:03 +08:00 committed by GitHub
parent 2677b88f5f
commit 526a78095a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,6 @@ export async function preloadRouteComponents (to: string, router: Router & { _ro
if (!router._routePreloaded) { router._routePreloaded = new Set() } if (!router._routePreloaded) { router._routePreloaded = new Set() }
if (router._routePreloaded.has(to)) { return } if (router._routePreloaded.has(to)) { return }
router._routePreloaded.add(to)
const promises = router._preloadPromises = router._preloadPromises || [] const promises = router._preloadPromises = router._preloadPromises || []
@ -48,6 +47,8 @@ export async function preloadRouteComponents (to: string, router: Router & { _ro
return Promise.all(promises).then(() => preloadRouteComponents(to, router)) return Promise.all(promises).then(() => preloadRouteComponents(to, router))
} }
router._routePreloaded.add(to)
const components = router.resolve(to).matched const components = router.resolve(to).matched
.map(component => component.components?.default) .map(component => component.components?.default)
.filter(component => typeof component === 'function') .filter(component => typeof component === 'function')