From: John Mao Date: Mon, 18 Mar 2024 14:02:17 +0000 (+0800) Subject: docs(zh): translate the redirect records note to Chinese and add it to migration... X-Git-Tag: v4.3.1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48ab495e375c7522e1637784eaf613c10066f080;p=thirdparty%2Fvuejs%2Frouter.git docs(zh): translate the redirect records note to Chinese and add it to migration (#2167) * docs(zh): translate the redirect records note to Chinese and add it to migration Refs (commit): 83b63f7 * Apply suggestions from code review --------- Co-authored-by: Jinjiang --- diff --git a/packages/docs/zh/guide/migration/index.md b/packages/docs/zh/guide/migration/index.md index 12aa944e..96d446e0 100644 --- a/packages/docs/zh/guide/migration/index.md +++ b/packages/docs/zh/guide/migration/index.md @@ -236,6 +236,15 @@ router.currentRoute.value.matched.flatMap(record => **原因**:这个方法只在 SSR 中使用,并且是用户一行就能完成的操作。 +### 重定向记录不能使用特殊路径 + +以前,有一个未被记录的特性允许将重定向记录设置为形如 `/events/:id` 的特殊路径,并且它会复用现有的参数 `id`。现在它已不再支持,有两个替代选项: + +- 使用不包含参数的路由名称:`redirect: { name: 'events' }`。注意,当参数 `:id` 为可选项时它不会生效 +- 使用一个函数重建基于目标的新位置:`redirect: to => ({ name: 'events', params: to.params })` + +**原因**:这种语法很少使用,是上述版本的*等效做法*,但是相比之下还不够简短,同时会引入一些复杂性,使路由器变得更重。 + ### **所有**的导航现在都是异步的 所有的导航,包括第一个导航,现在都是异步的,这意味着,如果你使用一个 `transition`,你可能需要等待路由 _ready_ 好后再挂载程序: