docs: add example to navigateTo util (#29611)

This commit is contained in:
Panopoulos Andreas 2024-10-20 13:02:56 +03:00 committed by GitHub
parent 0e9d22e198
commit 49242b2500
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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`