mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
docs(navigate-to): use await instead of return (#7734)
This commit is contained in:
parent
dffec69cda
commit
f4f6ed4304
@ -71,13 +71,13 @@ An object accepting the following properties:
|
|||||||
```vue
|
```vue
|
||||||
<script setup>
|
<script setup>
|
||||||
// passing 'to' as a string
|
// passing 'to' as a string
|
||||||
return navigateTo('/search')
|
await navigateTo('/search')
|
||||||
|
|
||||||
// ... or as a route object
|
// ... or as a route object
|
||||||
return navigateTo({ path: '/search' })
|
await navigateTo({ path: '/search' })
|
||||||
|
|
||||||
// ... or as a route object with query parameters
|
// ... or as a route object with query parameters
|
||||||
return navigateTo({
|
await navigateTo({
|
||||||
path: '/search',
|
path: '/search',
|
||||||
query: {
|
query: {
|
||||||
page: 1,
|
page: 1,
|
||||||
@ -103,13 +103,13 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|||||||
|
|
||||||
```vue
|
```vue
|
||||||
<script setup>
|
<script setup>
|
||||||
// will throw an error;
|
// will throw an error;
|
||||||
// navigating to an external URL is not allowed by default
|
// navigating to an external URL is not allowed by default
|
||||||
await navigateTo('https://v3.nuxtjs.org')
|
await navigateTo('https://v3.nuxtjs.org')
|
||||||
|
|
||||||
// will redirect successfully with the 'external' parameter set to 'true'
|
// will redirect successfully with the 'external' parameter set to 'true'
|
||||||
await navigateTo('https://v3.nuxtjs.org', {
|
await navigateTo('https://v3.nuxtjs.org', {
|
||||||
external: true
|
external: true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user