@nuxt/docs 3.19.2 → 3.20.0
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.
- package/1.getting-started/01.introduction.md +2 -2
- package/1.getting-started/02.installation.md +2 -1
- package/1.getting-started/03.configuration.md +29 -29
- package/1.getting-started/04.views.md +7 -7
- package/1.getting-started/05.assets.md +15 -9
- package/1.getting-started/06.styling.md +55 -45
- package/1.getting-started/07.routing.md +12 -12
- package/1.getting-started/08.seo-meta.md +55 -42
- package/1.getting-started/09.transitions.md +47 -42
- package/1.getting-started/10.data-fetching.md +90 -67
- package/1.getting-started/11.state-management.md +22 -15
- package/1.getting-started/12.error-handling.md +11 -9
- package/1.getting-started/13.server.md +3 -3
- package/1.getting-started/14.layers.md +21 -15
- package/1.getting-started/15.prerendering.md +28 -28
- package/1.getting-started/16.deployment.md +9 -9
- package/1.getting-started/17.testing.md +43 -43
- package/1.getting-started/18.upgrade.md +66 -61
- package/2.guide/0.index.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/0.output.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.assets.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.components.md +41 -24
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.composables.md +11 -11
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.layouts.md +16 -12
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.middleware.md +28 -22
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +6 -6
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.pages.md +33 -31
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.plugins.md +25 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +34 -34
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +6 -6
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.utils.md +5 -5
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +5 -5
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.app-config.md +12 -12
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.app.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.error.md +6 -6
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
- package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +18 -18
- package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +10 -10
- package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +9 -9
- package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +21 -19
- package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +5 -5
- package/2.guide/{1.concepts → 2.concepts}/5.modules.md +4 -4
- package/2.guide/{1.concepts → 2.concepts}/7.esm.md +20 -14
- package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +11 -11
- package/2.guide/3.going-further/1.events.md +2 -2
- package/2.guide/3.going-further/1.experimental-features.md +168 -80
- package/2.guide/3.going-further/1.features.md +15 -15
- package/2.guide/3.going-further/1.internals.md +25 -25
- package/2.guide/3.going-further/10.runtime-config.md +11 -11
- package/2.guide/3.going-further/2.hooks.md +11 -11
- package/2.guide/3.going-further/3.modules.md +119 -101
- package/2.guide/3.going-further/4.kit.md +5 -5
- package/2.guide/3.going-further/6.nuxt-app.md +5 -5
- package/2.guide/3.going-further/7.layers.md +75 -58
- package/2.guide/3.going-further/9.debugging.md +2 -2
- package/2.guide/4.recipes/1.custom-routing.md +31 -31
- package/2.guide/4.recipes/2.vite-plugin.md +45 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +12 -12
- package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
- package/2.guide/5.best-practices/hydration.md +4 -4
- package/2.guide/5.best-practices/performance.md +12 -12
- package/3.api/1.components/1.client-only.md +6 -3
- package/3.api/1.components/1.nuxt-client-fallback.md +9 -6
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +4 -1
- package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
- package/3.api/1.components/13.nuxt-time.md +49 -18
- package/3.api/1.components/2.nuxt-page.md +4 -4
- package/3.api/1.components/3.nuxt-layout.md +11 -6
- package/3.api/1.components/4.nuxt-link.md +40 -20
- package/3.api/1.components/5.nuxt-loading-indicator.md +2 -2
- package/3.api/1.components/6.nuxt-error-boundary.md +11 -9
- package/3.api/2.composables/on-prehydrate.md +2 -2
- package/3.api/2.composables/use-async-data.md +23 -19
- package/3.api/2.composables/use-cookie.md +28 -20
- package/3.api/2.composables/use-error.md +1 -1
- package/3.api/2.composables/use-fetch.md +59 -29
- package/3.api/2.composables/use-head-safe.md +7 -7
- package/3.api/2.composables/use-head.md +4 -4
- package/3.api/2.composables/use-hydration.md +6 -6
- package/3.api/2.composables/use-lazy-async-data.md +2 -2
- package/3.api/2.composables/use-lazy-fetch.md +2 -2
- package/3.api/2.composables/use-loading-indicator.md +12 -12
- package/3.api/2.composables/use-nuxt-app.md +19 -19
- package/3.api/2.composables/use-nuxt-data.md +8 -8
- package/3.api/2.composables/use-preview-mode.md +15 -18
- package/3.api/2.composables/use-request-event.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +3 -3
- package/3.api/2.composables/use-request-header.md +1 -1
- package/3.api/2.composables/use-request-headers.md +4 -4
- package/3.api/2.composables/use-request-url.md +1 -1
- package/3.api/2.composables/use-response-header.md +9 -10
- package/3.api/2.composables/use-route-announcer.md +4 -4
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +9 -7
- package/3.api/2.composables/use-runtime-config.md +6 -6
- package/3.api/2.composables/use-runtime-hook.md +2 -2
- package/3.api/2.composables/use-seo-meta.md +2 -2
- package/3.api/2.composables/use-server-seo-meta.md +4 -4
- package/3.api/2.composables/use-state.md +4 -4
- package/3.api/3.utils/$fetch.md +9 -7
- package/3.api/3.utils/abort-navigation.md +3 -3
- package/3.api/3.utils/add-route-middleware.md +5 -5
- package/3.api/3.utils/call-once.md +4 -4
- package/3.api/3.utils/clear-error.md +2 -2
- package/3.api/3.utils/clear-nuxt-data.md +3 -3
- package/3.api/3.utils/clear-nuxt-state.md +3 -3
- package/3.api/3.utils/create-error.md +1 -1
- package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
- package/3.api/3.utils/define-nuxt-component.md +5 -5
- package/3.api/3.utils/define-nuxt-plugin.md +12 -12
- package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
- package/3.api/3.utils/define-page-meta.md +21 -21
- package/3.api/3.utils/define-route-rules.md +5 -5
- package/3.api/3.utils/navigate-to.md +10 -10
- package/3.api/3.utils/prefetch-components.md +1 -1
- package/3.api/3.utils/preload-components.md +1 -1
- package/3.api/3.utils/prerender-routes.md +3 -3
- package/3.api/3.utils/refresh-cookie.md +3 -3
- package/3.api/3.utils/refresh-nuxt-data.md +11 -6
- package/3.api/3.utils/reload-nuxt-app.md +2 -2
- package/3.api/3.utils/set-page-layout.md +1 -1
- package/3.api/3.utils/set-response-status.md +2 -2
- package/3.api/3.utils/show-error.md +4 -4
- package/3.api/3.utils/update-app-config.md +3 -2
- package/3.api/4.commands/add.md +1 -1
- package/3.api/4.commands/analyze.md +2 -1
- package/3.api/4.commands/build.md +2 -1
- package/3.api/4.commands/dev.md +5 -4
- package/3.api/4.commands/generate.md +2 -1
- package/3.api/4.commands/init.md +3 -2
- package/3.api/4.commands/module.md +4 -4
- package/3.api/4.commands/prepare.md +7 -2
- package/3.api/4.commands/preview.md +5 -4
- package/3.api/4.commands/test.md +40 -0
- package/3.api/4.commands/typecheck.md +4 -2
- package/3.api/4.commands/upgrade.md +3 -3
- package/3.api/5.kit/1.modules.md +123 -37
- package/3.api/5.kit/10.runtime-config.md +1 -1
- package/3.api/5.kit/10.templates.md +8 -6
- package/3.api/5.kit/11.nitro.md +66 -62
- package/3.api/5.kit/12.resolving.md +2 -2
- package/3.api/5.kit/14.builder.md +61 -4
- package/3.api/5.kit/15.examples.md +5 -7
- package/3.api/5.kit/16.layers.md +26 -26
- package/3.api/5.kit/3.compatibility.md +12 -12
- package/3.api/5.kit/4.autoimports.md +13 -13
- package/3.api/5.kit/5.components.md +8 -7
- package/3.api/5.kit/6.context.md +3 -3
- package/3.api/5.kit/7.pages.md +7 -7
- package/3.api/5.kit/8.layout.md +2 -2
- package/3.api/5.kit/9.head.md +132 -0
- package/3.api/5.kit/9.plugins.md +6 -5
- package/3.api/6.advanced/1.hooks.md +4 -4
- package/3.api/6.advanced/2.import-meta.md +3 -3
- package/5.community/2.getting-help.md +1 -1
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/4.contribution.md +6 -6
- package/5.community/5.framework-contribution.md +3 -3
- package/5.community/6.roadmap.md +1 -1
- package/6.bridge/1.overview.md +13 -13
- package/6.bridge/10.configuration.md +2 -1
- package/6.bridge/2.typescript.md +2 -2
- package/6.bridge/3.bridge-composition-api.md +6 -6
- package/6.bridge/4.plugins-and-middleware.md +9 -9
- package/6.bridge/5.nuxt3-compatible-api.md +19 -16
- package/6.bridge/6.meta.md +20 -19
- package/6.bridge/7.runtime-config.md +1 -1
- package/6.bridge/8.nitro.md +3 -3
- package/6.bridge/9.vite.md +4 -4
- package/7.migration/1.overview.md +2 -2
- package/7.migration/2.configuration.md +22 -20
- package/7.migration/20.module-authors.md +6 -6
- package/7.migration/3.auto-imports.md +3 -3
- package/7.migration/4.meta.md +20 -17
- package/7.migration/5.plugins-and-middleware.md +5 -5
- package/7.migration/6.pages-and-layouts.md +23 -19
- package/7.migration/7.component-options.md +14 -14
- package/7.migration/8.runtime-config.md +6 -6
- package/package.json +1 -1
- /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
- /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
|
@@ -47,7 +47,7 @@ const userTheme = localStorage.getItem('theme') || 'light'
|
|
|
47
47
|
</script>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
**Solution**: You can use [`useCookie`](/docs/api/composables/use-cookie):
|
|
50
|
+
**Solution**: You can use [`useCookie`](/docs/3.x/api/composables/use-cookie):
|
|
51
51
|
|
|
52
52
|
```html
|
|
53
53
|
<template>
|
|
@@ -144,7 +144,7 @@ const greeting = hour < 12 ? 'Good morning' : 'Good afternoon'
|
|
|
144
144
|
</script>
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
**Solution**: Use [`NuxtTime`](/docs/api/components/nuxt-time) component or handle it client-side:
|
|
147
|
+
**Solution**: Use [`NuxtTime`](/docs/3.x/api/components/nuxt-time) component or handle it client-side:
|
|
148
148
|
|
|
149
149
|
```html
|
|
150
150
|
<template>
|
|
@@ -178,8 +178,8 @@ onMounted(() => {
|
|
|
178
178
|
|
|
179
179
|
## In summary
|
|
180
180
|
|
|
181
|
-
1. **Use SSR-friendly composables**: [`useFetch`](/docs/api/composables/use-fetch), [`useAsyncData`](/docs/api/composables/use-async-data), [`useState`](/docs/api/composables/use-state)
|
|
182
|
-
2. **Wrap client-only code**: Use [`ClientOnly`](/docs/api/components/client-only) component for browser-specific content
|
|
181
|
+
1. **Use SSR-friendly composables**: [`useFetch`](/docs/3.x/api/composables/use-fetch), [`useAsyncData`](/docs/3.x/api/composables/use-async-data), [`useState`](/docs/3.x/api/composables/use-state)
|
|
182
|
+
2. **Wrap client-only code**: Use [`ClientOnly`](/docs/3.x/api/components/client-only) component for browser-specific content
|
|
183
183
|
3. **Consistent data sources**: Ensure server and client uses the same data
|
|
184
184
|
4. **Avoid side effects in setup**: Move browser-dependent code to `onMounted`
|
|
185
185
|
|
|
@@ -12,7 +12,7 @@ Nuxt offers several built-in features that help you optimize performance of your
|
|
|
12
12
|
|
|
13
13
|
### Links
|
|
14
14
|
|
|
15
|
-
[`<NuxtLink>`](/docs/api/components/nuxt-link) is a drop-in replacement for both Vue Router's `<RouterLink>` component and HTML's `<a>` tag. It intelligently determines whether the link is internal or external and renders it accordingly with available optimizations (prefetching, default attributes, etc.)
|
|
15
|
+
[`<NuxtLink>`](/docs/3.x/api/components/nuxt-link) is a drop-in replacement for both Vue Router's `<RouterLink>` component and HTML's `<a>` tag. It intelligently determines whether the link is internal or external and renders it accordingly with available optimizations (prefetching, default attributes, etc.)
|
|
16
16
|
|
|
17
17
|
```html
|
|
18
18
|
<template>
|
|
@@ -34,8 +34,8 @@ export default defineNuxtConfig({
|
|
|
34
34
|
nuxtLink: {
|
|
35
35
|
prefetchOn: 'interaction',
|
|
36
36
|
},
|
|
37
|
-
}
|
|
38
|
-
}
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
39
|
})
|
|
40
40
|
```
|
|
41
41
|
|
|
@@ -51,18 +51,18 @@ Hybrid rendering allows different caching rules per route using Route Rules and
|
|
|
51
51
|
export default defineNuxtConfig({
|
|
52
52
|
routeRules: {
|
|
53
53
|
'/': {
|
|
54
|
-
prerender: true
|
|
54
|
+
prerender: true,
|
|
55
55
|
},
|
|
56
56
|
'/products/**': {
|
|
57
|
-
swr: 3600
|
|
57
|
+
swr: 3600,
|
|
58
58
|
},
|
|
59
59
|
'/blog': {
|
|
60
|
-
isr: 3600
|
|
60
|
+
isr: 3600,
|
|
61
61
|
},
|
|
62
62
|
'/admin/**': {
|
|
63
|
-
ssr: false
|
|
63
|
+
ssr: false,
|
|
64
64
|
},
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
66
|
})
|
|
67
67
|
```
|
|
68
68
|
|
|
@@ -110,7 +110,7 @@ To optimize your app, you may want to delay the hydration of some components unt
|
|
|
110
110
|
|
|
111
111
|
### Fetching data
|
|
112
112
|
|
|
113
|
-
To avoid fetching same data twice (once on the server and once on client) Nuxt provides [`useFetch`](/docs/api/composables/use-fetch) and [`useAsyncData`](/docs/api/composables/use-async-data). They ensure that if an API call is made on the server, the data is forwarded to the client in the payload instead of being fetched again.
|
|
113
|
+
To avoid fetching same data twice (once on the server and once on client) Nuxt provides [`useFetch`](/docs/3.x/api/composables/use-fetch) and [`useAsyncData`](/docs/3.x/api/composables/use-async-data). They ensure that if an API call is made on the server, the data is forwarded to the client in the payload instead of being fetched again.
|
|
114
114
|
|
|
115
115
|
:read-more{title="Data fetching" to="/docs/getting-started/data-fetching"}
|
|
116
116
|
|
|
@@ -126,7 +126,7 @@ In Nuxt we can use [Nuxt Image](https://image.nuxt.com/) module that is a plug-a
|
|
|
126
126
|
|
|
127
127
|
:video-accordion{title="Watch the video by LearnVue about Nuxt Image" videoId="_UBff2eqGY0"}
|
|
128
128
|
|
|
129
|
-
[`<NuxtImg>`](/docs/api/components/nuxt-img) is a drop-in replacement for the native `<img>` tag that comes with following enhancements:
|
|
129
|
+
[`<NuxtImg>`](/docs/3.x/api/components/nuxt-img) is a drop-in replacement for the native `<img>` tag that comes with following enhancements:
|
|
130
130
|
|
|
131
131
|
* Uses built-in provider to optimize local and remote images
|
|
132
132
|
* Converts `src` to provider optimized URLs with modern formats such as WebP or Avif
|
|
@@ -193,7 +193,7 @@ Nuxt Scripts provides an abstraction layer on top of third-party scripts, provid
|
|
|
193
193
|
|
|
194
194
|
```ts
|
|
195
195
|
const { onLoaded, proxy } = useScriptGoogleAnalytics(
|
|
196
|
-
{
|
|
196
|
+
{
|
|
197
197
|
id: 'G-1234567',
|
|
198
198
|
scriptOptions: {
|
|
199
199
|
trigger: 'manual',
|
|
@@ -216,7 +216,7 @@ To improve performance, we need to first know how to measure it, starting with m
|
|
|
216
216
|
|
|
217
217
|
### Nuxi Analyze
|
|
218
218
|
|
|
219
|
-
[This](/docs/api/commands/analyze) command of `nuxi` allows to analyze the production bundle or your Nuxt application. It leverages `vite-bundle-visualizer` (similar to `webpack-bundle-analyzer`) to generate a visual representation of your application's bundle, making it easier to identify which components take up the most space.
|
|
219
|
+
[This](/docs/3.x/api/commands/analyze) command of `nuxi` allows to analyze the production bundle or your Nuxt application. It leverages `vite-bundle-visualizer` (similar to `webpack-bundle-analyzer`) to generate a visual representation of your application's bundle, making it easier to identify which components take up the most space.
|
|
220
220
|
|
|
221
221
|
When you see a large block in the visualization, it often signals an opportunity for optimization—whether by splitting it into smaller parts, implementing lazy loading, or replacing it with a more efficient alternative, especially for third-party libraries.
|
|
222
222
|
|
|
@@ -24,7 +24,10 @@ The content of the default slot will be tree-shaken out of the server build. (Th
|
|
|
24
24
|
<div>
|
|
25
25
|
<Sidebar />
|
|
26
26
|
<!-- The <Comment> component will only be rendered on client-side -->
|
|
27
|
-
<ClientOnly
|
|
27
|
+
<ClientOnly
|
|
28
|
+
fallback-tag="span"
|
|
29
|
+
fallback="Loading comments..."
|
|
30
|
+
>
|
|
28
31
|
<Comment />
|
|
29
32
|
</ClientOnly>
|
|
30
33
|
</div>
|
|
@@ -40,7 +43,7 @@ The content of the default slot will be tree-shaken out of the server build. (Th
|
|
|
40
43
|
<div>
|
|
41
44
|
<Sidebar />
|
|
42
45
|
<!-- This renders the "span" element on the server side -->
|
|
43
|
-
<ClientOnly
|
|
46
|
+
<ClientOnly fallback-tag="span">
|
|
44
47
|
<!-- this component will only be rendered on client side -->
|
|
45
48
|
<Comments />
|
|
46
49
|
<template #fallback>
|
|
@@ -64,7 +67,7 @@ const nuxtWelcomeRef = useTemplateRef('nuxtWelcomeRef')
|
|
|
64
67
|
|
|
65
68
|
// The watch will be triggered when the component is available
|
|
66
69
|
watch(nuxtWelcomeRef, () => {
|
|
67
|
-
|
|
70
|
+
console.log('<NuxtWelcome /> mounted')
|
|
68
71
|
}, { once: true })
|
|
69
72
|
</script>
|
|
70
73
|
|
|
@@ -55,12 +55,15 @@ This component is experimental and in order to use it you must enable the `exper
|
|
|
55
55
|
- **default**: `false`
|
|
56
56
|
|
|
57
57
|
```vue
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
<template>
|
|
59
|
+
<!-- render <span>Hello world</span> server-side if the default slot fails to render -->
|
|
60
|
+
<NuxtClientFallback
|
|
61
|
+
fallback-tag="span"
|
|
62
|
+
fallback="Hello world"
|
|
63
|
+
>
|
|
64
|
+
<BrokeInSSR />
|
|
65
|
+
</NuxtClientFallback>
|
|
66
|
+
</template>
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
## Slots
|
|
@@ -10,7 +10,7 @@ links:
|
|
|
10
10
|
|
|
11
11
|
`<NuxtPicture>` is a drop-in replacement for the native `<picture>` tag.
|
|
12
12
|
|
|
13
|
-
Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
|
|
13
|
+
Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/3.x/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
|
|
14
14
|
|
|
15
15
|
Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture).
|
|
16
16
|
|
|
@@ -15,7 +15,10 @@ The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport.htm
|
|
|
15
15
|
Open Modal
|
|
16
16
|
</button>
|
|
17
17
|
<Teleport to="#teleports">
|
|
18
|
-
<div
|
|
18
|
+
<div
|
|
19
|
+
v-if="open"
|
|
20
|
+
class="modal"
|
|
21
|
+
>
|
|
19
22
|
<p>Hello from the modal!</p>
|
|
20
23
|
<button @click="open = false">
|
|
21
24
|
Close
|
|
@@ -16,7 +16,7 @@ This component is available in Nuxt v3.12+.
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/guide/directory-structure/app) or [`layouts/`](/docs/guide/directory-structure/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
|
|
19
|
+
Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/3.x/guide/directory-structure/app) or [`layouts/`](/docs/3.x/guide/directory-structure/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
|
|
20
20
|
|
|
21
21
|
```vue [app.vue]
|
|
22
22
|
<template>
|
|
@@ -32,13 +32,13 @@ Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/guide/directory-structure/
|
|
|
32
32
|
You can pass custom HTML or components through the route announcer's default slot.
|
|
33
33
|
|
|
34
34
|
```vue
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
<template>
|
|
36
|
+
<NuxtRouteAnnouncer>
|
|
37
|
+
<template #default="{ message }">
|
|
38
|
+
<p>{{ message }} was loaded.</p>
|
|
39
|
+
</template>
|
|
40
|
+
</NuxtRouteAnnouncer>
|
|
41
|
+
</template>
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## Props
|
|
@@ -52,5 +52,5 @@ To achieve full customization, you can implement your own one based on [its sour
|
|
|
52
52
|
::
|
|
53
53
|
|
|
54
54
|
::callout
|
|
55
|
-
You can hook into the underlying announcer instance using [the `useRouteAnnouncer` composable](/docs/api/composables/use-route-announcer), which allows you to set a custom announcement message.
|
|
55
|
+
You can hook into the underlying announcer instance using [the `useRouteAnnouncer` composable](/docs/3.x/api/composables/use-route-announcer), which allows you to set a custom announcement message.
|
|
56
56
|
::
|
|
@@ -56,7 +56,10 @@ The [BCP 47 language tag](https://datatracker.ietf.org/doc/html/rfc5646) for for
|
|
|
56
56
|
|
|
57
57
|
```vue
|
|
58
58
|
<template>
|
|
59
|
-
<NuxtTime
|
|
59
|
+
<NuxtTime
|
|
60
|
+
:datetime="Date.now()"
|
|
61
|
+
locale="fr-FR"
|
|
62
|
+
/>
|
|
60
63
|
</template>
|
|
61
64
|
```
|
|
62
65
|
|
|
@@ -66,8 +69,8 @@ The component accepts any property from the [Intl.DateTimeFormat](https://develo
|
|
|
66
69
|
|
|
67
70
|
```vue
|
|
68
71
|
<template>
|
|
69
|
-
<NuxtTime
|
|
70
|
-
:datetime="Date.now()"
|
|
72
|
+
<NuxtTime
|
|
73
|
+
:datetime="Date.now()"
|
|
71
74
|
year="numeric"
|
|
72
75
|
month="long"
|
|
73
76
|
day="numeric"
|
|
@@ -90,7 +93,10 @@ Enables relative time formatting using the Intl.RelativeTimeFormat API:
|
|
|
90
93
|
```vue
|
|
91
94
|
<template>
|
|
92
95
|
<!-- Shows something like "5 minutes ago" -->
|
|
93
|
-
<NuxtTime
|
|
96
|
+
<NuxtTime
|
|
97
|
+
:datetime="Date.now() - 5 * 60 * 1000"
|
|
98
|
+
relative
|
|
99
|
+
/>
|
|
94
100
|
</template>
|
|
95
101
|
```
|
|
96
102
|
|
|
@@ -98,13 +104,17 @@ Enables relative time formatting using the Intl.RelativeTimeFormat API:
|
|
|
98
104
|
|
|
99
105
|
When `relative` is set to `true`, the component also accepts properties from [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat):
|
|
100
106
|
|
|
107
|
+
::warning
|
|
108
|
+
Due to `style` being a reserved prop, `relativeStyle` prop is used instead.
|
|
109
|
+
::
|
|
110
|
+
|
|
101
111
|
```vue
|
|
102
112
|
<template>
|
|
103
|
-
<NuxtTime
|
|
104
|
-
:datetime="Date.now() - 3 * 24 * 60 * 60 * 1000"
|
|
105
|
-
relative
|
|
113
|
+
<NuxtTime
|
|
114
|
+
:datetime="Date.now() - 3 * 24 * 60 * 60 * 1000"
|
|
115
|
+
relative
|
|
106
116
|
numeric="auto"
|
|
107
|
-
style="long"
|
|
117
|
+
relative-style="long"
|
|
108
118
|
/>
|
|
109
119
|
</template>
|
|
110
120
|
```
|
|
@@ -125,8 +135,8 @@ This would output something like: "3 days ago" or "last Friday" depending on the
|
|
|
125
135
|
|
|
126
136
|
```vue
|
|
127
137
|
<template>
|
|
128
|
-
<NuxtTime
|
|
129
|
-
:datetime="Date.now()"
|
|
138
|
+
<NuxtTime
|
|
139
|
+
:datetime="Date.now()"
|
|
130
140
|
weekday="long"
|
|
131
141
|
year="numeric"
|
|
132
142
|
month="short"
|
|
@@ -134,7 +144,7 @@ This would output something like: "3 days ago" or "last Friday" depending on the
|
|
|
134
144
|
hour="numeric"
|
|
135
145
|
minute="numeric"
|
|
136
146
|
second="numeric"
|
|
137
|
-
|
|
147
|
+
time-zone-name="short"
|
|
138
148
|
/>
|
|
139
149
|
</template>
|
|
140
150
|
```
|
|
@@ -145,15 +155,24 @@ This would output something like: "3 days ago" or "last Friday" depending on the
|
|
|
145
155
|
<template>
|
|
146
156
|
<div>
|
|
147
157
|
<p>
|
|
148
|
-
<NuxtTime
|
|
158
|
+
<NuxtTime
|
|
159
|
+
:datetime="Date.now() - 30 * 1000"
|
|
160
|
+
relative
|
|
161
|
+
/>
|
|
149
162
|
<!-- 30 seconds ago -->
|
|
150
163
|
</p>
|
|
151
|
-
<p>
|
|
152
|
-
<NuxtTime
|
|
164
|
+
<p>
|
|
165
|
+
<NuxtTime
|
|
166
|
+
:datetime="Date.now() - 45 * 60 * 1000"
|
|
167
|
+
relative
|
|
168
|
+
/>
|
|
153
169
|
<!-- 45 minutes ago -->
|
|
154
170
|
</p>
|
|
155
171
|
<p>
|
|
156
|
-
<NuxtTime
|
|
172
|
+
<NuxtTime
|
|
173
|
+
:datetime="Date.now() + 2 * 24 * 60 * 60 * 1000"
|
|
174
|
+
relative
|
|
175
|
+
/>
|
|
157
176
|
<!-- in 2 days -->
|
|
158
177
|
</p>
|
|
159
178
|
</div>
|
|
@@ -165,9 +184,21 @@ This would output something like: "3 days ago" or "last Friday" depending on the
|
|
|
165
184
|
```vue
|
|
166
185
|
<template>
|
|
167
186
|
<div>
|
|
168
|
-
<NuxtTime
|
|
169
|
-
|
|
170
|
-
|
|
187
|
+
<NuxtTime
|
|
188
|
+
:datetime="Date.now()"
|
|
189
|
+
locale="en-US"
|
|
190
|
+
weekday="long"
|
|
191
|
+
/>
|
|
192
|
+
<NuxtTime
|
|
193
|
+
:datetime="Date.now()"
|
|
194
|
+
locale="fr-FR"
|
|
195
|
+
weekday="long"
|
|
196
|
+
/>
|
|
197
|
+
<NuxtTime
|
|
198
|
+
:datetime="Date.now()"
|
|
199
|
+
locale="ja-JP"
|
|
200
|
+
weekday="long"
|
|
201
|
+
/>
|
|
171
202
|
</div>
|
|
172
203
|
</template>
|
|
173
204
|
```
|
|
@@ -8,7 +8,7 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`pages/`](/docs/guide/directory-structure/pages) directory.
|
|
11
|
+
`<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`pages/`](/docs/3.x/guide/directory-structure/pages) directory.
|
|
12
12
|
|
|
13
13
|
::note
|
|
14
14
|
`<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/RouterViewProps.html#interface-routerviewprops) from Vue Router. It should be used instead of `<RouterView>` because the former takes additional care of internal states. Otherwise, `useRoute()` may return incorrect paths.
|
|
@@ -18,7 +18,7 @@ links:
|
|
|
18
18
|
|
|
19
19
|
```vue
|
|
20
20
|
<template>
|
|
21
|
-
<RouterView
|
|
21
|
+
<RouterView v-slot="{ Component }">
|
|
22
22
|
<!-- Optional, when using transitions -->
|
|
23
23
|
<Transition>
|
|
24
24
|
<!-- Optional, when using keep-alive -->
|
|
@@ -79,12 +79,12 @@ You can also use a dynamic key based on the current route:
|
|
|
79
79
|
Don't use `$route` object here as it can cause problems with how `<NuxtPage>` renders pages with `<Suspense>`.
|
|
80
80
|
::
|
|
81
81
|
|
|
82
|
-
Alternatively, `pageKey` can be passed as a `key` value via [`definePageMeta`](/docs/api/utils/define-page-meta) from the `<script>` section of your Vue component in the `/pages` directory.
|
|
82
|
+
Alternatively, `pageKey` can be passed as a `key` value via [`definePageMeta`](/docs/3.x/api/utils/define-page-meta) from the `<script>` section of your Vue component in the `/pages` directory.
|
|
83
83
|
|
|
84
84
|
```vue [pages/my-page.vue]
|
|
85
85
|
<script setup lang="ts">
|
|
86
86
|
definePageMeta({
|
|
87
|
-
key: route => route.fullPath
|
|
87
|
+
key: route => route.fullPath,
|
|
88
88
|
})
|
|
89
89
|
</script>
|
|
90
90
|
```
|
|
@@ -22,7 +22,7 @@ You can use `<NuxtLayout />` component to activate the `default` layout on `app.
|
|
|
22
22
|
|
|
23
23
|
## Props
|
|
24
24
|
|
|
25
|
-
- `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/guide/directory-structure/layouts) directory.
|
|
25
|
+
- `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/3.x/guide/directory-structure/layouts) directory.
|
|
26
26
|
- **type**: `string`
|
|
27
27
|
- **default**: `default`
|
|
28
28
|
|
|
@@ -55,7 +55,7 @@ Please note the layout name is normalized to kebab-case, so if your layout file
|
|
|
55
55
|
Read more about dynamic layouts.
|
|
56
56
|
::
|
|
57
57
|
|
|
58
|
-
- `fallback`: If an invalid layout is passed to the `name` prop, no layout will be rendered. Specify a `fallback` layout to be rendered in this scenario. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/guide/directory-structure/layouts) directory.
|
|
58
|
+
- `fallback`: If an invalid layout is passed to the `name` prop, no layout will be rendered. Specify a `fallback` layout to be rendered in this scenario. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/3.x/guide/directory-structure/layouts) directory.
|
|
59
59
|
- **type**: `string`
|
|
60
60
|
- **default**: `null`
|
|
61
61
|
|
|
@@ -66,8 +66,11 @@ Read more about dynamic layouts.
|
|
|
66
66
|
```vue [pages/some-page.vue]
|
|
67
67
|
<template>
|
|
68
68
|
<div>
|
|
69
|
-
<NuxtLayout
|
|
70
|
-
|
|
69
|
+
<NuxtLayout
|
|
70
|
+
name="custom"
|
|
71
|
+
title="I am a custom layout"
|
|
72
|
+
>
|
|
73
|
+
<!-- ... -->
|
|
71
74
|
</NuxtLayout>
|
|
72
75
|
</div>
|
|
73
76
|
</template>
|
|
@@ -93,7 +96,9 @@ console.log(layoutCustomProps.title) // I am a custom layout
|
|
|
93
96
|
<template>
|
|
94
97
|
<div>
|
|
95
98
|
<NuxtLayout name="custom">
|
|
96
|
-
<template #header>
|
|
99
|
+
<template #header>
|
|
100
|
+
Some header template content.
|
|
101
|
+
</template>
|
|
97
102
|
</NuxtLayout>
|
|
98
103
|
</div>
|
|
99
104
|
</template>
|
|
@@ -139,7 +144,7 @@ function logFoo () {
|
|
|
139
144
|
<script setup lang="ts">
|
|
140
145
|
const foo = () => console.log('foo')
|
|
141
146
|
defineExpose({
|
|
142
|
-
foo
|
|
147
|
+
foo,
|
|
143
148
|
})
|
|
144
149
|
</script>
|
|
145
150
|
|
|
@@ -67,7 +67,10 @@ For static files in the `/public` directory, such as PDFs or images, use the `ex
|
|
|
67
67
|
|
|
68
68
|
```vue [pages/index.vue]
|
|
69
69
|
<template>
|
|
70
|
-
<NuxtLink
|
|
70
|
+
<NuxtLink
|
|
71
|
+
to="/example-report.pdf"
|
|
72
|
+
external
|
|
73
|
+
>
|
|
71
74
|
Download Report
|
|
72
75
|
</NuxtLink>
|
|
73
76
|
</template>
|
|
@@ -79,7 +82,10 @@ When pointing to a different application on the same domain, using the `external
|
|
|
79
82
|
|
|
80
83
|
```vue [pages/index.vue]
|
|
81
84
|
<template>
|
|
82
|
-
<NuxtLink
|
|
85
|
+
<NuxtLink
|
|
86
|
+
to="/another-app"
|
|
87
|
+
external
|
|
88
|
+
>
|
|
83
89
|
Go to Another App
|
|
84
90
|
</NuxtLink>
|
|
85
91
|
</template>
|
|
@@ -117,12 +123,18 @@ When you need to overwrite this behavior you can use the `rel` or `noRel` props.
|
|
|
117
123
|
</NuxtLink>
|
|
118
124
|
<!-- <a href="https://twitter.com/nuxt_js" rel="noopener noreferrer">...</a> -->
|
|
119
125
|
|
|
120
|
-
<NuxtLink
|
|
126
|
+
<NuxtLink
|
|
127
|
+
to="https://discord.nuxtjs.org"
|
|
128
|
+
rel="noopener"
|
|
129
|
+
>
|
|
121
130
|
Nuxt Discord
|
|
122
131
|
</NuxtLink>
|
|
123
132
|
<!-- <a href="https://discord.nuxtjs.org" rel="noopener">...</a> -->
|
|
124
133
|
|
|
125
|
-
<NuxtLink
|
|
134
|
+
<NuxtLink
|
|
135
|
+
to="/about"
|
|
136
|
+
target="_blank"
|
|
137
|
+
>About page</NuxtLink>
|
|
126
138
|
<!-- <a href="/about" target="_blank" rel="noopener noreferrer">...</a> -->
|
|
127
139
|
</template>
|
|
128
140
|
```
|
|
@@ -131,7 +143,10 @@ A `noRel` prop can be used to prevent the default `rel` attribute from being add
|
|
|
131
143
|
|
|
132
144
|
```vue [app.vue]
|
|
133
145
|
<template>
|
|
134
|
-
<NuxtLink
|
|
146
|
+
<NuxtLink
|
|
147
|
+
to="https://github.com/nuxt"
|
|
148
|
+
no-rel
|
|
149
|
+
>
|
|
135
150
|
Nuxt GitHub
|
|
136
151
|
</NuxtLink>
|
|
137
152
|
<!-- <a href="https://github.com/nuxt">...</a> -->
|
|
@@ -147,8 +162,13 @@ A `noRel` prop can be used to prevent the default `rel` attribute from being add
|
|
|
147
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.
|
|
148
163
|
|
|
149
164
|
```vue [pages/index.vue]
|
|
150
|
-
<NuxtLink to="/about" no-prefetch>
|
|
151
|
-
|
|
165
|
+
<NuxtLink to="/about" no-prefetch>
|
|
166
|
+
About page not pre-fetched
|
|
167
|
+
</NuxtLink>
|
|
168
|
+
|
|
169
|
+
<NuxtLink to="/about" :prefetch="false">
|
|
170
|
+
About page not pre-fetched
|
|
171
|
+
</NuxtLink>
|
|
152
172
|
```
|
|
153
173
|
|
|
154
174
|
### Custom Prefetch Triggers
|
|
@@ -238,7 +258,7 @@ When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink`
|
|
|
238
258
|
- `href`: An alias for `to`. If used with `to`, `href` will be ignored
|
|
239
259
|
- `noRel`: If set to `true`, no `rel` attribute will be added to the external link
|
|
240
260
|
- `external`: Forces the link to be rendered as an `<a>` tag instead of a Vue Router `RouterLink`.
|
|
241
|
-
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/api/nuxt-config#crossoriginprefetch)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/api/nuxt-config#crossoriginprefetch) config.
|
|
261
|
+
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/3.x/api/nuxt-config#crossoriginprefetch)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/3.x/api/nuxt-config#crossoriginprefetch) config.
|
|
242
262
|
- `prefetchOn`: Allows custom control of when to prefetch links. Possible options are `interaction` and `visibility` (default). You can also pass an object for full control, for example: `{ interaction: true, visibility: true }`. This prop is only used when `prefetch` is enabled (default) and `noPrefetch` is not set.
|
|
243
263
|
- `noPrefetch`: Disables prefetching.
|
|
244
264
|
- `prefetchedClass`: A class to apply to links that have been prefetched.
|
|
@@ -256,7 +276,7 @@ Defaults can be overwritten, see [overwriting defaults](#overwriting-defaults) i
|
|
|
256
276
|
|
|
257
277
|
### In Nuxt Config
|
|
258
278
|
|
|
259
|
-
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/api/nuxt-config#defaults)
|
|
279
|
+
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/3.x/api/nuxt-config#defaults)
|
|
260
280
|
|
|
261
281
|
::important
|
|
262
282
|
These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
|
|
@@ -273,12 +293,12 @@ export default defineNuxtConfig({
|
|
|
273
293
|
activeClass: 'router-link-active',
|
|
274
294
|
exactActiveClass: 'router-link-exact-active',
|
|
275
295
|
prefetchedClass: undefined, // can be any valid string class name
|
|
276
|
-
trailingSlash: undefined // can be 'append' or 'remove'
|
|
296
|
+
trailingSlash: undefined, // can be 'append' or 'remove'
|
|
277
297
|
prefetch: true,
|
|
278
|
-
prefetchOn: { visibility: true }
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
298
|
+
prefetchOn: { visibility: true },
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
282
302
|
})
|
|
283
303
|
```
|
|
284
304
|
|
|
@@ -286,7 +306,7 @@ export default defineNuxtConfig({
|
|
|
286
306
|
|
|
287
307
|
You can overwrite `<NuxtLink>` defaults by creating your own link component using `defineNuxtLink`.
|
|
288
308
|
|
|
289
|
-
```
|
|
309
|
+
```ts [components/MyNuxtLink.ts]
|
|
290
310
|
export default defineNuxtLink({
|
|
291
311
|
componentName: 'MyNuxtLink',
|
|
292
312
|
/* see signature below for more */
|
|
@@ -299,10 +319,10 @@ You can then use `<MyNuxtLink />` component as usual with your new defaults.
|
|
|
299
319
|
|
|
300
320
|
```ts
|
|
301
321
|
interface NuxtLinkOptions {
|
|
302
|
-
componentName?: string
|
|
303
|
-
externalRelAttribute?: string
|
|
304
|
-
activeClass?: string
|
|
305
|
-
exactActiveClass?: string
|
|
322
|
+
componentName?: string
|
|
323
|
+
externalRelAttribute?: string
|
|
324
|
+
activeClass?: string
|
|
325
|
+
exactActiveClass?: string
|
|
306
326
|
trailingSlash?: 'append' | 'remove'
|
|
307
327
|
prefetch?: boolean
|
|
308
328
|
prefetchedClass?: string
|
|
@@ -311,7 +331,7 @@ interface NuxtLinkOptions {
|
|
|
311
331
|
interaction: boolean
|
|
312
332
|
}>
|
|
313
333
|
}
|
|
314
|
-
function defineNuxtLink(options: NuxtLinkOptions): Component {}
|
|
334
|
+
function defineNuxtLink (options: NuxtLinkOptions): Component {}
|
|
315
335
|
```
|
|
316
336
|
|
|
317
337
|
- `componentName`: A name for the component. Default is `NuxtLink`.
|
|
@@ -10,7 +10,7 @@ links:
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/guide/directory-structure/app) or [`layouts/`](/docs/guide/directory-structure/layouts).
|
|
13
|
+
Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/3.x/guide/directory-structure/app) or [`layouts/`](/docs/3.x/guide/directory-structure/layouts).
|
|
14
14
|
|
|
15
15
|
```vue [app.vue]
|
|
16
16
|
<template>
|
|
@@ -42,7 +42,7 @@ To achieve full customization, you can implement your own one based on [its sour
|
|
|
42
42
|
::
|
|
43
43
|
|
|
44
44
|
::note
|
|
45
|
-
You can hook into the underlying indicator instance using [the `useLoadingIndicator` composable](/docs/api/composables/use-loading-indicator), which will allow you to trigger start/finish events yourself.
|
|
45
|
+
You can hook into the underlying indicator instance using [the `useLoadingIndicator` composable](/docs/3.x/api/composables/use-loading-indicator), which will allow you to trigger start/finish events yourself.
|
|
46
46
|
::
|
|
47
47
|
|
|
48
48
|
::tip
|
|
@@ -29,16 +29,18 @@ The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/c
|
|
|
29
29
|
- `#error`: Specify a fallback content to display in case of error.
|
|
30
30
|
|
|
31
31
|
```vue
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
<template>
|
|
33
|
+
<NuxtErrorBoundary>
|
|
34
|
+
<!-- ... -->
|
|
35
|
+
<template #error="{ error, clearError }">
|
|
36
|
+
<p>An error occurred: {{ error }}</p>
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
<button @click="clearError">
|
|
39
|
+
Clear error
|
|
40
|
+
</button>
|
|
41
|
+
</template>
|
|
42
|
+
</NuxtErrorBoundary>
|
|
43
|
+
</template>
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
:read-more{to="/docs/getting-started/error-handling"}
|
|
@@ -24,8 +24,8 @@ Call `onPrehydrate` in the setup function of a Vue component (e.g., in `<script
|
|
|
24
24
|
## Type
|
|
25
25
|
|
|
26
26
|
```ts [Signature]
|
|
27
|
-
export function onPrehydrate(callback: (el: HTMLElement) => void): void
|
|
28
|
-
export function onPrehydrate(callback: string | ((el: HTMLElement) => void), key?: string): undefined | string
|
|
27
|
+
export function onPrehydrate (callback: (el: HTMLElement) => void): void
|
|
28
|
+
export function onPrehydrate (callback: string | ((el: HTMLElement) => void), key?: string): undefined | string
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Parameters
|