Skip to content

Commit b9416cb

Browse files
GuitoEnriqueSahjacobmllr95
authored
feat: support <nuxt-link>'s prefetch property (closes #5125) (#5355)
* Adding prefetch property to links * Update common-props.json * Update header.vue * Update README.md * Update avatar.js * Update link.js * Update pagination-nav.js * Update README.md Co-authored-by: Enrique González <enrique.gonzalez@speakingathome.com> Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
1 parent 41680ba commit b9416cb

File tree

6 files changed

+337
-345
lines changed

6 files changed

+337
-345
lines changed

docs/common-props.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@
230230
"event": {
231231
"description": "router-link prop: Specify the event that triggers the link. In most cases you should leave this as the default"
232232
},
233+
"prefetch": {
234+
"description": "nuxt-link prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting 'prefetch' to 'true' or 'false' will overwrite the default value of 'router.prefetchLinks'"
235+
},
233236
"noPrefetch": {
234237
"description": "nuxt-link prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting 'no-prefetch' will disabled this feature for the specific link"
235238
}

docs/markdown/reference/router-links/README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,18 @@ render a [`<nuxt-link>`](https://nuxtjs.org/api/components-nuxt-link) sub compon
155155
`<router-link>`. `<nuxt-link>` supports all of the above router link props, plus the following
156156
additional Nuxt.js specific props.
157157

158-
### `no-prefetch`
158+
### `prefetch`
159159

160160
- type: `boolean`
161-
- default: `false`
162-
- availability: Nuxt.js 2.4.0+
161+
- default: `undefined`
162+
- availability: Nuxt.js 2.10.0+
163163

164164
To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within
165-
the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `no-prefetch` will
166-
disabled this feature for the specific link.
165+
the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `prefetch` to
166+
`true` or `false` will overwrite the default value of `router.prefetchLinks` configured in the
167+
`nuxt.config.js` configuration file.
167168

168-
**Note:** If you have prefetching disabled in your `nuxt.config.js` configuration
169-
(`router: { prefetchLinks: false}`), or are using a version of Nuxt.js `< 2.4.0`, then this prop
170-
will have no effect.
169+
**Note:** If you have are using a version of Nuxt.js `< 2.10.0`, then this prop will have no effect.
171170

172171
Prefetching support requires
173172
[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
@@ -187,3 +186,17 @@ export default {
187186
}
188187
}
189188
```
189+
190+
### `no-prefetch`
191+
192+
- type: `boolean`
193+
- default: `false`
194+
- availability: Nuxt.js 2.4.0+
195+
196+
To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within
197+
the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `no-prefetch` will
198+
disabled this feature for the specific link.
199+
200+
**Note:** If you have prefetching disabled in your `nuxt.config.js` configuration
201+
(`router: { prefetchLinks: false }`), or are using a version of Nuxt.js `< 2.4.0`, then this prop
202+
will have no effect.

0 commit comments

Comments
 (0)