Skip to content

Commit

Permalink
docs: relative redirect improvement (vuejs#1090)
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo San Martin Morote <[email protected]>
  • Loading branch information
Yukon123 and posva authored Aug 24, 2021
1 parent 45d3ba0 commit 8e89064
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/guide/essentials/redirect-and-alias.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const routes = [
]
```

Note that **[Navigation Guards](../advanced/navigation-guards.md) are not applied on the route that redirects, only on its target**. e.g. In the example below, adding a `beforeEnter` guard to the `/home` route would not have any effect.
Note that **[Navigation Guards](../advanced/navigation-guards.md) are not applied on the route that redirects, only on its target**. e.g. In the above example, adding a `beforeEnter` guard to the `/home` route would not have any effect.

When writing a `redirect`, you can omit the `component` option because it is never directly reached so there is no component to render. The only exception are [nested routes](./nested-routes.md): if a route record has `children` and a `redirect` property, it should also have a `component` property.

Expand All @@ -45,10 +45,13 @@ It's also possible to redirect to a relative location:
```js
const routes = [
{
// will always redirect /users/123/posts to /users/123/profile
path: '/users/:id/posts',
redirect: to => {
// the function receives the target route as the argument
// return redirect path/location here.
// a relative location doesn't start with `/`
// or { path: 'profile'}
return 'profile'
},
},
]
Expand Down

0 comments on commit 8e89064

Please sign in to comment.