docs: add example of passing params to <NuxtLink> (#27284)

This commit is contained in:
Kim-Lan 2024-05-20 15:19:34 -07:00 committed by GitHub
parent a618a5c1d1
commit 9a33892cec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,6 +25,22 @@ In this example, we use `<NuxtLink>` component to link to another page of the ap
</template> </template>
``` ```
### Passing Params to Dynamic Routes
In this example, we pass the `id` param to link to the route `~/pages/posts/[id].vue`.
```vue [pages/index.vue]
<template>
<NuxtLink :to="{ name: 'posts-id', params: { id: 123 } }">
Post 123
</NuxtLink>
</template>
```
::tip
Check out the Pages panel in Nuxt DevTools to see the route name and the params it might take.
::
### Handling 404s ### Handling 404s
When using `<NuxtLink>` for `/public` directory files or when pointing to a different app on the same domain, you should use the `external` prop. When using `<NuxtLink>` for `/public` directory files or when pointing to a different app on the same domain, you should use the `external` prop.