From aad0d48e0106dac0a1ede6f2b623bf9d2f367737 Mon Sep 17 00:00:00 2001 From: stonelee Date: Thu, 5 Dec 2024 16:53:04 +0800 Subject: [PATCH] docs: incorrect description of content in the dynamic-routing section (#2413) --- packages/docs/guide/advanced/dynamic-routing.md | 2 +- packages/docs/zh/guide/advanced/dynamic-routing.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docs/guide/advanced/dynamic-routing.md b/packages/docs/guide/advanced/dynamic-routing.md index 5488b2fa3..6e5179bc3 100644 --- a/packages/docs/guide/advanced/dynamic-routing.md +++ b/packages/docs/guide/advanced/dynamic-routing.md @@ -50,7 +50,7 @@ router.beforeEach(to => { }) ``` -The example above assumes two things: first, the newly added route record will match the `to` location, effectively resulting in a different location from the one we were trying to access. Second, `hasNecessaryRoute()` returns `false` after adding the new route to avoid an infinite redirection. +The example above assumes two things: first, the newly added route record will match the `to` location, effectively resulting in a different location from the one we were trying to access. Second, `hasNecessaryRoute()` returns `true` after adding the new route to avoid an infinite redirection. Because we are redirecting, we are replacing the ongoing navigation, effectively behaving like the example shown before. In real world scenarios, adding is more likely to happen outside of navigation guards, e.g. when a view component mounts, it register new routes. diff --git a/packages/docs/zh/guide/advanced/dynamic-routing.md b/packages/docs/zh/guide/advanced/dynamic-routing.md index ba7b602d3..543c43a79 100644 --- a/packages/docs/zh/guide/advanced/dynamic-routing.md +++ b/packages/docs/zh/guide/advanced/dynamic-routing.md @@ -50,7 +50,7 @@ router.beforeEach(to => { }) ``` -上面的例子有两个假设:第一,新添加的路由记录将与 `to` 位置相匹配,实际上导致与我们试图访问的位置不同。第二,`hasNecessaryRoute()` 在添加新的路由后返回 `false`,以避免无限重定向。 +上面的例子有两个假设:第一,新添加的路由记录将与 `to` 位置相匹配,实际上导致与我们试图访问的位置不同。第二,`hasNecessaryRoute()` 在添加新的路由后返回 `true`,以避免无限重定向。 因为是在重定向中,所以我们是在替换将要跳转的导航,实际上行为就像之前的例子一样。而在实际场景中,添加路由的行为更有可能发生在导航守卫之外,例如,当一个视图组件挂载时,它会注册新的路由。