@nuxt/docs-nightly 5.0.0-29732421.92bcb2f1 → 5.0.0-29732458.f413c04a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -161,6 +161,8 @@ A `noRel` prop can be used to prevent the default `rel` attribute from being add
|
|
|
161
161
|
|
|
162
162
|
Nuxt automatically includes smart prefetching. That means it detects when a link is visible (by default), either in the viewport or when scrolling and prefetches the JavaScript for those pages so that they are ready when the user clicks the link. Nuxt only loads the resources when the browser isn't busy and skips prefetching if your connection is offline or if you only have 2g connection.
|
|
163
163
|
|
|
164
|
+
When using the `custom` prop, `<NuxtLink>` does not automatically attach prefetch handlers. You can call `prefetch` from the custom slot yourself.
|
|
165
|
+
|
|
164
166
|
```vue [app/pages/index.vue]
|
|
165
167
|
<NuxtLink to="/about" no-prefetch>
|
|
166
168
|
About page not pre-fetched
|
|
@@ -212,6 +214,27 @@ That you probably don't want both enabled!
|
|
|
212
214
|
|
|
213
215
|
This configuration will observe when the element enters the viewport and also listen for `pointerenter` and `focus` events. This may result in unnecessary resource usage or redundant prefetching, as both triggers can prefetch the same resource under different conditions.
|
|
214
216
|
|
|
217
|
+
When using `custom`, prefetching is controlled by your slot implementation:
|
|
218
|
+
|
|
219
|
+
```vue
|
|
220
|
+
<template>
|
|
221
|
+
<NuxtLink
|
|
222
|
+
v-slot="{ href, navigate, prefetch, shouldPrefetch }"
|
|
223
|
+
to="/about"
|
|
224
|
+
custom
|
|
225
|
+
>
|
|
226
|
+
<a
|
|
227
|
+
:href="href"
|
|
228
|
+
@click="navigate"
|
|
229
|
+
@pointerenter="shouldPrefetch('interaction') && prefetch()"
|
|
230
|
+
@focus="shouldPrefetch('interaction') && prefetch()"
|
|
231
|
+
>
|
|
232
|
+
About page
|
|
233
|
+
</a>
|
|
234
|
+
</NuxtLink>
|
|
235
|
+
</template>
|
|
236
|
+
```
|
|
237
|
+
|
|
215
238
|
### Enable Cross-origin Prefetch
|
|
216
239
|
|
|
217
240
|
To enable cross-origin prefetching, you can set the `crossOriginPrefetch` option in your `nuxt.config`. This will enable cross-origin prefetching using the [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API).
|
|
@@ -263,6 +286,10 @@ When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink`
|
|
|
263
286
|
- `noPrefetch`: Disables prefetching.
|
|
264
287
|
- `prefetchedClass`: A class to apply to links that have been prefetched.
|
|
265
288
|
|
|
289
|
+
::note
|
|
290
|
+
With the `custom` prop, `prefetch`, `prefetchOn` and `prefetchedClass` do not attach handlers or classes automatically. Use the custom slot's `prefetch`, `prefetched` and `shouldPrefetch` values to implement this behavior.
|
|
291
|
+
::
|
|
292
|
+
|
|
266
293
|
### Anchor
|
|
267
294
|
|
|
268
295
|
- `target`: A `target` attribute value to apply on the link
|