Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update examples of dynamic pageKey #22920

Merged
merged 2 commits into from Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/2.guide/2.directory-structure/1.pages.md
Expand Up @@ -205,7 +205,7 @@ If you want more control over when the `<NuxtPage>` component is re-rendered (fo
<template>
<div>
<h1>I am the parent view</h1>
<NuxtPage :page-key="someKey" />
<NuxtPage :page-key="route => route.fullPath" />
</div>
</template>
```
Expand Down
6 changes: 6 additions & 0 deletions docs/3.api/2.components/2.nuxt-page.md
Expand Up @@ -34,6 +34,12 @@ For example, passing `static` key, `NuxtPage` component is rendered only once wh
<NuxtPage page-key="static" />
```

You can also use a dynamic key based on the current route. (Don't use `$route` object here as it can cause problems with how `<NuxtPage>` renders pages with `<Suspense>`.)

```html
<NuxtPage :page-key="route => route.fullPath" />
```

Alternatively, `pageKey` can be passed as a `key` value via `definePageMeta` from the `<script>` section of your Vue component in the `/pages` directory.

```js
Expand Down