mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-15 02:14:44 +00:00
docs: add example to navigateTo util (#29611)
This commit is contained in:
parent
0e9d22e198
commit
49242b2500
@ -125,6 +125,19 @@ Make sure to always use `await` or `return` on result of `navigateTo` when calli
|
|||||||
|
|
||||||
`to` can be a plain string or a route object to redirect to. When passed as `undefined` or `null`, it will default to `'/'`.
|
`to` can be a plain string or a route object to redirect to. When passed as `undefined` or `null`, it will default to `'/'`.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Passing the URL directly will redirect to the '/blog' page
|
||||||
|
await navigateTo('/blog')
|
||||||
|
|
||||||
|
// Using the route object, will redirect to the route with the name 'blog'
|
||||||
|
await navigateTo({ name: 'blog' })
|
||||||
|
|
||||||
|
// Redirects to the 'product' route while passing a parameter (id = 1) using the route object.
|
||||||
|
await navigateTo({ name: 'product', params: { id: 1 } })
|
||||||
|
```
|
||||||
|
|
||||||
### `options` (optional)
|
### `options` (optional)
|
||||||
|
|
||||||
**Type**: `NavigateToOptions`
|
**Type**: `NavigateToOptions`
|
||||||
|
Loading…
Reference in New Issue
Block a user