From: Yukon123 <82578034+Yukon123@users.noreply.github.com> Date: Tue, 24 Aug 2021 08:10:06 +0000 (+0800) Subject: docs: relative redirect improvement (#1090) X-Git-Tag: v4.0.12~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e890640d6f2c8f44251ec9f6be2e76aaeb09c57;p=thirdparty%2Fvuejs%2Frouter.git docs: relative redirect improvement (#1090) Co-authored-by: Eduardo San Martin Morote --- diff --git a/docs/guide/essentials/redirect-and-alias.md b/docs/guide/essentials/redirect-and-alias.md index 89eff33b..d825aa5d 100644 --- a/docs/guide/essentials/redirect-and-alias.md +++ b/docs/guide/essentials/redirect-and-alias.md @@ -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. @@ -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' }, }, ]