Describe the feature
In earlier issue, I mention a feature request that preloadRouteComponents allows passing values of type RouteLocationRaw👉 #18845 .
But I fund that the <NuxtLink> prefetch (or preload) just only execute when the props to type is string,
<!-- Passing a string -->
<!-- It will prefetch -->
<NuxtLink to="/home"> Home </NuxtLink>
<!-- Passing a string with query string -->
<!-- It will prefetch -->
<NuxtLink to="/home?year=2023"> Home </NuxtLink>
<!-- Passing a object -->
<!-- It will no prefetch -->
<NuxtLink :to="{ name: 'home', query: { year: '2023' } }"> Home </NuxtLink>
That's because of the following code:
|
const shouldPrefetch = props.prefetch !== false && props.noPrefetch !== true && typeof to.value === 'string' && props.target !== '_blank' && !isSlowConnection() |
|
if (shouldPrefetch) { |
One of the conditions for shouldPrefetch is typeof to.value === 'string'.
Is this expected? Or can this limit be remove?
If allow prefetch when <NuxtLink> to passing a value type of RouteLocationRaw, the app runtime lifecycle hook link:prefetch type must also be updated together
|
'link:prefetch': (link: string) => HookResult |
Additional information
Final checks
Describe the feature
In earlier issue, I mention a feature request that
preloadRouteComponentsallows passing values of typeRouteLocationRaw👉 #18845 .But I fund that the
<NuxtLink>prefetch (or preload) just only execute when the propstotype is string,That's because of the following code:
nuxt/packages/nuxt/src/app/components/nuxt-link.ts
Lines 179 to 180 in 524426e
One of the conditions for
shouldPrefetchistypeof to.value === 'string'.Is this expected? Or can this limit be remove?
If allow prefetch when
<NuxtLink>to passing a value type ofRouteLocationRaw, the app runtime lifecycle hooklink:prefetchtype must also be updated togethernuxt/packages/nuxt/src/app/nuxt.ts
Line 38 in 524426e
Additional information
Final checks