docs(navigate-to): use await instead of return (#7734)

This commit is contained in:
Reinier Kaper 2022-09-22 09:23:07 -04:00 committed by GitHub
parent dffec69cda
commit f4f6ed4304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,13 +71,13 @@ An object accepting the following properties:
```vue
<script setup>
// passing 'to' as a string
return navigateTo('/search')
await navigateTo('/search')
// ... or as a route object
return navigateTo({ path: '/search' })
await navigateTo({ path: '/search' })
// ... or as a route object with query parameters
return navigateTo({
await navigateTo({
path: '/search',
query: {
page: 1,
@ -103,13 +103,13 @@ export default defineNuxtRouteMiddleware((to, from) => {
```vue
<script setup>
// will throw an error;
// navigating to an external URL is not allowed by default
await navigateTo('https://v3.nuxtjs.org')
// will throw an error;
// navigating to an external URL is not allowed by default
await navigateTo('https://v3.nuxtjs.org')
// will redirect successfully with the 'external' parameter set to 'true'
await navigateTo('https://v3.nuxtjs.org', {
external: true
})
// will redirect successfully with the 'external' parameter set to 'true'
await navigateTo('https://v3.nuxtjs.org', {
external: true
})
</script>
```