]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs(zh): sync update to 35a9c1b (#2084)
authorJinjiang <zhaojinjiang@me.com>
Wed, 20 Dec 2023 16:44:44 +0000 (00:44 +0800)
committerGitHub <noreply@github.com>
Wed, 20 Dec 2023 16:44:44 +0000 (00:44 +0800)
35 files changed:
packages/docs/.vitepress/config/zh.ts
packages/docs/.vitepress/translation-status.json
packages/docs/zh/api/index.md
packages/docs/zh/api/interfaces/NavigationGuard.md
packages/docs/zh/api/interfaces/NavigationGuardWithThis.md
packages/docs/zh/api/interfaces/RouteLocationMatched.md
packages/docs/zh/api/interfaces/RouteLocationNormalized.md
packages/docs/zh/api/interfaces/RouteMeta.md
packages/docs/zh/api/interfaces/RouteRecordBase.md [new file with mode: 0644]
packages/docs/zh/api/interfaces/RouteRecordMultipleViews.md [new file with mode: 0644]
packages/docs/zh/api/interfaces/RouteRecordMultipleViewsWithChildren.md [new file with mode: 0644]
packages/docs/zh/api/interfaces/RouteRecordNormalized.md
packages/docs/zh/api/interfaces/RouteRecordRedirect.md [new file with mode: 0644]
packages/docs/zh/api/interfaces/RouteRecordSingleView.md [new file with mode: 0644]
packages/docs/zh/api/interfaces/RouteRecordSingleViewWithChildren.md [new file with mode: 0644]
packages/docs/zh/api/interfaces/Router.md
packages/docs/zh/api/interfaces/RouterHistory.md
packages/docs/zh/api/interfaces/RouterOptions.md
packages/docs/zh/api/interfaces/RouterScrollBehavior.md
packages/docs/zh/guide/advanced/dynamic-routing.md
packages/docs/zh/guide/advanced/lazy-loading.md
packages/docs/zh/guide/advanced/meta.md
packages/docs/zh/guide/advanced/navigation-failures.md
packages/docs/zh/guide/advanced/navigation-guards.md
packages/docs/zh/guide/advanced/router-view-slot.md [new file with mode: 0644]
packages/docs/zh/guide/advanced/scroll-behavior.md
packages/docs/zh/guide/advanced/transitions.md
packages/docs/zh/guide/essentials/history-mode.md
packages/docs/zh/guide/essentials/named-routes.md
packages/docs/zh/guide/essentials/named-views.md
packages/docs/zh/guide/essentials/navigation.md
packages/docs/zh/guide/essentials/passing-props.md
packages/docs/zh/guide/index.md
packages/docs/zh/guide/migration/index.md
packages/docs/zh/installation.md

index 0776b666667f6f27437a109022ddd6a05ebd8701..83068e02a89fcf8888bc246d7d8ab5dfad818aee 100644 (file)
@@ -48,6 +48,10 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
             text: '更新日志',
             link: 'https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md',
           },
+          {
+            text: 'Vue.js 认证',
+            link: 'https://certification.vuejs.org/?friend=VUEROUTER',
+          },
         ],
       },
     ],
@@ -139,6 +143,10 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
               text: '组合式 API',
               link: '/zh/guide/advanced/composition-api.html',
             },
+            {
+              text: 'RouterView 插槽',
+              link: '/guide/advanced/router-view-slot.html',
+            },
             {
               text: '过渡动效',
               link: '/zh/guide/advanced/transitions.html',
index 1a2101278ff7d580124ff8fbec83d0304f7af184..ea46a91271b857ebdc9397032ba53039f27abf4c 100644 (file)
@@ -1,6 +1,6 @@
 {
   "zh": {
-    "hash": "1a3a28f",
-    "date": "2023-04-08"
+    "hash": "35a9c1b",
+    "date": "2023-12-16"
   }
-}
+}
\ No newline at end of file
index 63efd7c2af4edc878d191b05ecb8ffc20d8e83d5..3d1183ae40dd689d652f3b98cee7ef19e4e9a094 100644 (file)
@@ -20,19 +20,25 @@ API 文档
 - [RouteLocationNormalizedLoaded](interfaces/RouteLocationNormalizedLoaded.md)
 - [RouteLocationOptions](interfaces/RouteLocationOptions.md)
 - [RouteMeta](interfaces/RouteMeta.md)
+- [RouteRecordMultipleViews](interfaces/RouteRecordMultipleViews.md)
+- [RouteRecordMultipleViewsWithChildren](interfaces/RouteRecordMultipleViewsWithChildren.md)
 - [RouteRecordNormalized](interfaces/RouteRecordNormalized.md)
+- [RouteRecordRedirect](interfaces/RouteRecordRedirect.md)
+- [RouteRecordSingleView](interfaces/RouteRecordSingleView.md)
+- [RouteRecordSingleViewWithChildren](interfaces/RouteRecordSingleViewWithChildren.md)
 - [Router](interfaces/Router.md)
 - [RouterHistory](interfaces/RouterHistory.md)
 - [RouterLinkProps](interfaces/RouterLinkProps.md)
 - [RouterOptions](interfaces/RouterOptions.md)
 - [RouterScrollBehavior](interfaces/RouterScrollBehavior.md)
 - [RouterViewProps](interfaces/RouterViewProps.md)
+- [\_RouteRecordBase](interfaces/RouteRecordBase.md)
 
 ## TS 类型别名 %{#Type-Aliases}%
 
 ### LocationQuery %{#Type-Aliases-LocationQuery}%
 
-Ƭ **LocationQuery**: `Record`<`string`, `LocationQueryValue` \| `LocationQueryValue`[]\>
+Ƭ **LocationQuery**: `Record`\<`string`, `LocationQueryValue` \| `LocationQueryValue`[]\>
 
 出现在 [RouteLocationNormalized](interfaces/RouteLocationNormalized.md) 中的规范化查询对象。
 
@@ -40,17 +46,17 @@ ___
 
 ### LocationQueryRaw %{#Type-Aliases-LocationQueryRaw}%
 
-Ƭ **LocationQueryRaw**: `Record`<`string` \| `number`, `LocationQueryValueRaw` \| `LocationQueryValueRaw`[]\>
+Ƭ **LocationQueryRaw**: `Record`\<`string` \| `number`, `LocationQueryValueRaw` \| `LocationQueryValueRaw`[]\>
 
 松散的 [LocationQuery](index.md#locationquery) 对象,可以被传递给诸如
-[push](interfaces/Router.md#push)、[replace](interfaces/Router.md#replace) 或任何创建
+[Router.push](interfaces/Router.md#push)、[Router.replace](interfaces/Router.md#replace) 或任何创建
 [RouteLocationRaw](index.md#routelocationraw) 的函数。
 
 ___
 
 ### PathParserOptions %{#Type-Aliases-PathParserOptions}%
 
-Ƭ **PathParserOptions**: `Pick`<`_PathParserOptions`, ``"end"`` \| ``"sensitive"`` \| ``"strict"``\>
+Ƭ **PathParserOptions**: `Pick`\<`_PathParserOptions`, ``"end"`` \| ``"sensitive"`` \| ``"strict"``\>
 
 ___
 
@@ -72,13 +78,13 @@ ___
 
 ### RouteParams %{#Type-Aliases-RouteParams}%
 
-Ƭ **RouteParams**: `Record`<`string`, `RouteParamValue` \| `RouteParamValue`[]\>
+Ƭ **RouteParams**: `Record`\<`string`, `RouteParamValue` \| `RouteParamValue`[]\>
 
 ___
 
 ### RouteParamsRaw %{#Type-Aliases-RouteParamsRaw}%
 
-Ƭ **RouteParamsRaw**: `Record`<`string`, `RouteParamValueRaw` \| `Exclude`<`RouteParamValueRaw`, ``null`` \| `undefined`\>[]\>
+Ƭ **RouteParamsRaw**: `Record`\<`string`, `RouteParamValueRaw` \| `Exclude`\<`RouteParamValueRaw`, ``null`` \| `undefined`\>[]\>
 
 ___
 
@@ -100,13 +106,13 @@ ___
 
 ### RouteRecordRaw %{#Type-Aliases-RouteRecordRaw}%
 
-Ƭ **RouteRecordRaw**: `RouteRecordSingleView` \| `RouteRecordSingleViewWithChildren` \| `RouteRecordMultipleViews` \| `RouteRecordMultipleViewsWithChildren` \| `RouteRecordRedirect`
+Ƭ **RouteRecordRaw**: [`RouteRecordSingleView`](interfaces/RouteRecordSingleView.md) \| [`RouteRecordSingleViewWithChildren`](interfaces/RouteRecordSingleViewWithChildren.md) \| [`RouteRecordMultipleViews`](interfaces/RouteRecordMultipleViews.md) \| [`RouteRecordMultipleViewsWithChildren`](interfaces/RouteRecordMultipleViewsWithChildren.md) \| [`RouteRecordRedirect`](interfaces/RouteRecordRedirect.md)
 
 ___
 
 ### UseLinkOptions %{#Type-Aliases-UseLinkOptions}%
 
-Ƭ **UseLinkOptions**: `VueUseOptions`<`RouterLinkOptions`\>
+Ƭ **UseLinkOptions**: `VueUseOptions`\<`RouterLinkOptions`\>
 
 ## 变量 %{#Variables}%
 
@@ -120,14 +126,24 @@ ___
 
 ### RouterView %{#Variables-RouterView}%
 
-• `Const` **RouterView**: () => { `$props`: `AllowedComponentProps` & `ComponentCustomProps` & `VNodeProps` & [`RouterViewProps`](interfaces/RouterViewProps.md) ; `$slots`: { `default?`: (`__namedParameters`: { `Component`: `VNode`<`RendererNode`, `RendererElement`, { `[key: string]`: `any`;  }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)  }) => `VNode`<`RendererNode`, `RendererElement`, { `[key: string]`: `any`;  }\>[]  }  }
+• `Const` **RouterView**: () => \{ `$props`: `AllowedComponentProps` & `ComponentCustomProps` & `VNodeProps` & [`RouterViewProps`](interfaces/RouterViewProps.md) ; `$slots`: \{ `default?`: (`__namedParameters`: \{ `Component`: `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`;  }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)  }) => `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`;  }\>[]  }  }
 
 #### 类型声明 %{#Variables-RouterView-Type-declaration}%
 
-• **new RouterView**()
+• **new RouterView**(): `Object`
 
 用于显示用户当前所处路由的组件。
 
+##### 返回值 %{#Variables-RouterView-Returns}%
+
+`Object`
+
+| 名称 | 类型 |
+| :------ | :------ |
+| `$props` | `AllowedComponentProps` & `ComponentCustomProps` & `VNodeProps` & [`RouterViewProps`](interfaces/RouterViewProps.md) |
+| `$slots` | \{ `default?`: (`__namedParameters`: \{ `Component`: `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`;  }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)  }) => `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`;  }\>[]  } |
+| `$slots.default?` | (`__namedParameters`: \{ `Component`: `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`;  }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)  }) => `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`;  }\>[] |
+
 ___
 
 ### START\_LOCATION %{#Variables-START_LOCATION}%
@@ -194,6 +210,16 @@ ___
 
 创建一个 hash 模式的历史。在没有主机的 web 应用 (如 `file://`) 或无法通过配置服务器来处理任意 URL 的时候非常有用。
 
+#### 参数 %{#Functions-createWebHashHistory-Parameters}%
+
+| 名称 | 类型 | 描述 |
+| :------ | :------ | :------ |
+| `base?` | `string` | 可选提供的基础位置。默认为 `location.pathname + location.search`。如果在 `head` 中有一个 `<base>` 标签,它的值会因此被忽略,**但注意它会影响所有 history.pushState() 的调用**,这意味着如果你使用一个 `<base>` 标签,它的 `href` 值**必须与这个参数匹配** (忽略 `#` 后的任何东西)。 |
+
+#### 返回值 %{#Functions-createWebHashHistory-Returns}%
+
+[`RouterHistory`](interfaces/RouterHistory.md)
+
 **示例**
 
 ```js
@@ -210,16 +236,6 @@ createWebHashHistory('/other-folder/') // 给出一个 `https://example.com/othe
 createWebHashHistory('/iAmIgnored') // 给出一个 `file:///usr/etc/folder/index.html#` 的 URL
 ```
 
-#### 参数 %{#Functions-createWebHashHistory-Parameters}%
-
-| 名称 | 类型 | 描述 |
-| :------ | :------ | :------ |
-| `base?` | `string` | 可选提供的基础位置。默认为 `location.pathname + location.search`。如果在 `head` 中有一个 `<base>` 标签,它的值会因此被忽略,**但注意它会影响所有 history.pushState() 的调用**,这意味着如果你使用一个 `<base>` 标签,它的 `href` 值**必须与这个参数匹配** (忽略 `#` 后的任何东西)。 |
-
-#### 返回值 %{#Functions-createWebHashHistory-Returns}%
-
-[`RouterHistory`](interfaces/RouterHistory.md)
-
 ___
 
 ### createWebHistory %{#Functions-createWebHistory}%
@@ -246,6 +262,17 @@ ___
 
 检查一个对象是否是 [NavigationFailure](interfaces/NavigationFailure.md)。
 
+#### 参数 %{#Functions-isNavigationFailure-Parameters}%
+
+| 名称 | 类型 | 描述 |
+| :------ | :------ | :------ |
+| `error` | `any` | 可能的 [NavigationFailure](interfaces/NavigationFailure.md) |
+| `type?` | `NAVIGATION_GUARD_REDIRECT` | 可选的待检查类型 |
+
+#### 返回值 %{#Functions-isNavigationFailure-Returns}%
+
+error is NavigationRedirectError
+
 **示例**
 
 ```js
@@ -267,17 +294,6 @@ router.afterEach((to, from, failure) => {
 })
 ```
 
-#### 参数 %{#Functions-isNavigationFailure-Parameters}%
-
-| 名称 | 类型 | 描述 |
-| :------ | :------ | :------ |
-| `error` | `any` | 可能的 [NavigationFailure](interfaces/NavigationFailure.md) |
-| `type?` | `NAVIGATION_GUARD_REDIRECT` | 可选的待检查类型 |
-
-#### 返回值 %{#Functions-isNavigationFailure-Returns}%
-
-error is NavigationRedirectError
-
 ▸ **isNavigationFailure**(`error`, `type?`): error is NavigationFailure
 
 #### 参数 %{#Functions-isNavigationFailure-Parameters_1}%
@@ -295,7 +311,7 @@ ___
 
 ### loadRouteLocation %{#Functions-loadRouteLocation}%
 
-▸ **loadRouteLocation**(`route`): `Promise`<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\>
+▸ **loadRouteLocation**(`route`): `Promise`\<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\>
 
 确保路由被加载,所以它可以作为一个 prop 传递给 `<RouterView>`。
 
@@ -307,7 +323,7 @@ ___
 
 #### 返回值 %{#Functions-loadRouteLocation-Returns}%
 
-`Promise`<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\>
+`Promise`\<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\>
 
 ___
 
@@ -355,7 +371,7 @@ ___
 
 | 名称 | 类型 |
 | :------ | :------ |
-| `props` | `VueUseOptions`<`RouterLinkOptions`\> |
+| `props` | `VueUseOptions`\<`RouterLinkOptions`\> |
 
 #### 返回值 %{#Functions-useLink-Returns}%
 
@@ -364,10 +380,10 @@ ___
 | 名称 | 类型 |
 | :------ | :------ |
 | `href` | `ComputedRef<string\>` |
-| `isActive` | `ComputedRef`<`boolean`\> |
-| `isExactActive` | `ComputedRef`<`boolean`\> |
-| `navigate` | (`e`: `MouseEvent`) => `Promise`<`void` \| [`NavigationFailure`](interfaces/NavigationFailure.md)\> |
-| `route` | `ComputedRef`<[`RouteLocation`](interfaces/RouteLocation.md) & { `href`: `string`  }\> |
+| `isActive` | `ComputedRef`\<`boolean`\> |
+| `isExactActive` | `ComputedRef`\<`boolean`\> |
+| `navigate` | (`e`: `MouseEvent`) => `Promise`\<`void` \| [`NavigationFailure`](interfaces/NavigationFailure.md)\> |
+| `route` | `ComputedRef`\<[`RouteLocation`](interfaces/RouteLocation.md) & { `href`: `string`  }\> |
 
 ___
 
index 10c1d0aef126b4e2ba4549779959b6396fe6e051..52a86b69b680b484fa901cfe5b1378c15eea4711 100644 (file)
@@ -6,13 +6,13 @@ editLink: false
 
 # 接口:NavigationGuard %{#interface-navigationguard}%
 
+导航守卫。详情可查阅[导航守卫](/zh/guide/advanced/navigation-guards.md)。
+
 ## 可调用函数 %{#Callable}%
 
 ### NavigationGuard %{#Callable-NavigationGuard}%
 
-▸ **NavigationGuard**(`to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\>
-
-导航守卫。详情可查阅[导航守卫](/zh/guide/advanced/navigation-guards.md).
+▸ **NavigationGuard**(`to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\>
 
 #### 参数 %{#Callable-NavigationGuard-Parameters}%
 
@@ -24,4 +24,4 @@ editLink: false
 
 #### 返回值 %{#Callable-NavigationGuard-Returns}%
 
-`NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\>
+`NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\>
index dc89efa70ee8e513d14690958c2e7e29f95ecdcc..1a82c2d657a7bd24251753595ed69957476288c3 100644 (file)
@@ -4,7 +4,9 @@ editLink: false
 
 [API 参考](../index.md) / NavigationGuardWithThis
 
-# 接口:NavigationGuardWithThis<T\> %{#interface-navigationguardwiththis-t}%
+# 接口:NavigationGuardWithThis\<T\> %{#interface-navigationguardwiththis-t}%
+
+导航守卫。详情可查阅[导航守卫](/zh/guide/advanced/navigation-guards.md)。
 
 ## 类型参数 %{#Type-parameters}%
 
@@ -16,9 +18,7 @@ editLink: false
 
 ### NavigationGuardWithThis %{#Callable-NavigationGuardWithThis}%
 
-▸ **NavigationGuardWithThis**(`this`, `to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\>
-
-导航守卫。详情可查阅[导航守卫](/zh/guide/advanced/navigation-guards.md).
+▸ **NavigationGuardWithThis**(`this`, `to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\>
 
 #### 参数 %{#Callable-NavigationGuardWithThis-Parameters}%
 
@@ -31,4 +31,4 @@ editLink: false
 
 #### 返回值 %{#Callable-NavigationGuardWithThis-Returns}%
 
-`NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\>
+`NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\>
index 3b8d089845d24b223e1f592dfa05b0bacb45b682..ea52970a1f051155a0a1195a69941ff09d5ddf57 100644 (file)
@@ -30,7 +30,7 @@ ___
 
 ### beforeEnter %{#Properties-beforeEnter}%
 
-• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[]
+• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
 
 被注册的 beforeEnter 守卫
 
@@ -54,7 +54,7 @@ ___
 
 ### components %{#Properties-components}%
 
-• **components**: `undefined` \| ``null`` \| `Record`<`string`, [`RouteComponent`](../index.md#routecomponent)\>
+• **components**: `undefined` \| ``null`` \| `Record`\<`string`, [`RouteComponent`](../index.md#routecomponent)\>
 
 {@inheritDoc RouteRecordMultipleViews.components}
 
@@ -66,7 +66,7 @@ ___
 
 ### instances %{#Properties-instances}%
 
-• **instances**: `Record`<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`<{}, {}, {}, {}, {}, {}, {}, {}, ``false``, `ComponentOptionsBase`<`any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, {}, {}, `string`\>, {}\>\>
+• **instances**: `Record`\<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`\>
 
 <!-- TODO: translation -->
 
@@ -82,7 +82,9 @@ ___
 
 • **meta**: [`RouteMeta`](RouteMeta.md)
 
-{@inheritDoc _RouteRecordBase.meta}
+<!-- TODO: translation -->
+
+Arbitrary data attached to the record.
 
 #### 继承自 %{#Properties-meta-Inherited-from}%
 
@@ -94,7 +96,9 @@ ___
 
 • **name**: `undefined` \| [`RouteRecordName`](../index.md#routerecordname)
 
-{@inheritDoc _RouteRecordBase.name}
+<!-- TODO: translation -->
+
+Name for the route record. Must be unique.
 
 #### 继承自 %{#Properties-name-Inherited-from}%
 
@@ -106,7 +110,9 @@ ___
 
 • **path**: `string`
 
-{@inheritDoc _RouteRecordBase.path}
+<!-- TODO: translation -->
+
+Path of the record. Should start with `/` unless the record is the child of another record.
 
 #### 继承自 %{#Properties-path-Inherited-from}%
 
@@ -116,9 +122,11 @@ ___
 
 ### props %{#Properties-props}%
 
-• **props**: `Record`<`string`, `_RouteRecordProps`\>
+• **props**: `Record`\<`string`, `_RouteRecordProps`\>
+
+<!-- TODO: translation -->
 
-{@inheritDoc RouteRecordMultipleViews.props}
+Allow passing down params as props to the component rendered by `router-view`. Should be an object with the same keys as `components` or a boolean to be applied to every component.
 
 #### 继承自 %{#Properties-props-Inherited-from}%
 
@@ -130,7 +138,9 @@ ___
 
 • **redirect**: `undefined` \| `RouteRecordRedirectOption`
 
-{@inheritDoc _RouteRecordBase.redirect}
+<!-- TODO: translation -->
+
+Where to redirect if the route is directly matched. The redirection happens before any navigation guard and triggers a new navigation with the new target location.
 
 #### 继承自 %{#Properties-redirect-Inherited-from}%
 
index 820dc7e501909e0a69453b13fbf9910eee94df3c..b0ae66d6474c23814f6ca078f514b901762320c9 100644 (file)
@@ -6,7 +6,7 @@ editLink: false
 
 # 接口:RouteLocationNormalized
 
-和 [RouteLocation](RouteLocation.md) 类似但是其 [matched](RouteLocationNormalized.md#matched) 无法包含重定向的记录
+和 [RouteLocation](RouteLocation.md) 类似但是其 [RouteLocationNormalized.matched](RouteLocationNormalized.md#matched) 无法包含重定向的记录
 
 ## 继承关系 %{#Hierarchy}%
 
index d7fdb4c096d6bfc9511111629d3a3bf139ef5c51..0e3ad6132afc782784cfd15252db36e0ce383fff 100644 (file)
@@ -23,6 +23,6 @@ declare module 'vue-router' {
 
 ## 继承关系 %{#Hierarchy}%
 
-- `Record`<`string` \| `number` \| `symbol`, `unknown`\>
+- `Record`\<`string` \| `number` \| `symbol`, `unknown`\>
 
   ↳ **`RouteMeta`**
diff --git a/packages/docs/zh/api/interfaces/RouteRecordBase.md b/packages/docs/zh/api/interfaces/RouteRecordBase.md
new file mode 100644 (file)
index 0000000..0958b0d
--- /dev/null
@@ -0,0 +1,151 @@
+---
+editLink: false
+---
+
+<!-- TODO: translation -->
+
+[API Documentation](../index.md) / \_RouteRecordBase
+
+# Interface: \_RouteRecordBase
+
+Internal type for common properties among all kind of [RouteRecordRaw](../index.md#RouteRecordRaw).
+
+## Hierarchy
+
+- [`PathParserOptions`](../index.md#PathParserOptions)
+
+  ↳ **`_RouteRecordBase`**
+
+  ↳↳ [`RouteRecordSingleView`](RouteRecordSingleView.md)
+
+  ↳↳ [`RouteRecordSingleViewWithChildren`](RouteRecordSingleViewWithChildren.md)
+
+  ↳↳ [`RouteRecordMultipleViews`](RouteRecordMultipleViews.md)
+
+  ↳↳ [`RouteRecordMultipleViewsWithChildren`](RouteRecordMultipleViewsWithChildren.md)
+
+  ↳↳ [`RouteRecordRedirect`](RouteRecordRedirect.md)
+
+## Properties
+
+### alias
+
+• `Optional` **alias**: `string` \| `string`[]
+
+Aliases for the record. Allows defining extra paths that will behave like a
+copy of the record. Allows having paths shorthands like `/users/:id` and
+`/u/:id`. All `alias` and `path` values must share the same params.
+
+___
+
+### beforeEnter
+
+• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
+
+Before Enter guard specific to this record. Note `beforeEnter` has no
+effect if the record has a `redirect` property.
+
+___
+
+### children
+
+• `Optional` **children**: [`RouteRecordRaw`](../index.md#RouteRecordRaw)[]
+
+Array of nested routes.
+
+___
+
+### end
+
+• `Optional` **end**: `boolean`
+
+Should the RegExp match until the end by appending a `$` to it.
+
+**`Default Value`**
+
+`true`
+
+#### Inherited from
+
+PathParserOptions.end
+
+___
+
+### meta
+
+• `Optional` **meta**: [`RouteMeta`](RouteMeta.md)
+
+Arbitrary data attached to the record.
+
+___
+
+### name
+
+• `Optional` **name**: [`RouteRecordName`](../index.md#RouteRecordName)
+
+Name for the route record. Must be unique.
+
+___
+
+### path
+
+• **path**: `string`
+
+Path of the record. Should start with `/` unless the record is the child of
+another record.
+
+**`Example`**
+
+```ts
+`/users/:id` matches `/users/1` as well as `/users/posva`.
+```
+
+___
+
+### props
+
+• `Optional` **props**: `_RouteRecordProps` \| `Record`\<`string`, `_RouteRecordProps`\>
+
+Allow passing down params as props to the component rendered by `router-view`.
+
+___
+
+### redirect
+
+• `Optional` **redirect**: `RouteRecordRedirectOption`
+
+Where to redirect if the route is directly matched. The redirection happens
+before any navigation guard and triggers a new navigation with the new
+target location.
+
+___
+
+### sensitive
+
+• `Optional` **sensitive**: `boolean`
+
+Makes the RegExp case-sensitive.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+PathParserOptions.sensitive
+
+___
+
+### strict
+
+• `Optional` **strict**: `boolean`
+
+Whether to disallow a trailing slash or not.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+PathParserOptions.strict
diff --git a/packages/docs/zh/api/interfaces/RouteRecordMultipleViews.md b/packages/docs/zh/api/interfaces/RouteRecordMultipleViews.md
new file mode 100644 (file)
index 0000000..c18ffd1
--- /dev/null
@@ -0,0 +1,189 @@
+---
+editLink: false
+---
+
+<!-- TODO: translation -->
+
+[API Documentation](../index.md) / RouteRecordMultipleViews
+
+# Interface: RouteRecordMultipleViews
+
+Route Record defining multiple named components with the `components` option.
+
+## Hierarchy
+
+- [`_RouteRecordBase`](RouteRecordBase.md)
+
+  ↳ **`RouteRecordMultipleViews`**
+
+## Properties
+
+### alias
+
+• `Optional` **alias**: `string` \| `string`[]
+
+Aliases for the record. Allows defining extra paths that will behave like a
+copy of the record. Allows having paths shorthands like `/users/:id` and
+`/u/:id`. All `alias` and `path` values must share the same params.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[alias](RouteRecordBase.md#alias)
+
+___
+
+### beforeEnter
+
+• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
+
+Before Enter guard specific to this record. Note `beforeEnter` has no
+effect if the record has a `redirect` property.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[beforeEnter](RouteRecordBase.md#beforeEnter)
+
+___
+
+### children
+
+• `Optional` **children**: `undefined`
+
+Array of nested routes.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[children](RouteRecordBase.md#children)
+
+___
+
+### component
+
+• `Optional` **component**: `undefined`
+
+___
+
+### components
+
+• **components**: `Record`\<`string`, `RawRouteComponent`\>
+
+Components to display when the URL matches this route. Allow using named views.
+
+___
+
+### end
+
+• `Optional` **end**: `boolean`
+
+Should the RegExp match until the end by appending a `$` to it.
+
+**`Default Value`**
+
+`true`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[end](RouteRecordBase.md#end)
+
+___
+
+### meta
+
+• `Optional` **meta**: [`RouteMeta`](RouteMeta.md)
+
+Arbitrary data attached to the record.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[meta](RouteRecordBase.md#meta)
+
+___
+
+### name
+
+• `Optional` **name**: [`RouteRecordName`](../index.md#RouteRecordName)
+
+Name for the route record. Must be unique.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[name](RouteRecordBase.md#name)
+
+___
+
+### path
+
+• **path**: `string`
+
+Path of the record. Should start with `/` unless the record is the child of
+another record.
+
+**`Example`**
+
+```ts
+`/users/:id` matches `/users/1` as well as `/users/posva`.
+```
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[path](RouteRecordBase.md#path)
+
+___
+
+### props
+
+• `Optional` **props**: `boolean` \| `Record`\<`string`, `_RouteRecordProps`\>
+
+Allow passing down params as props to the component rendered by
+`router-view`. Should be an object with the same keys as `components` or a
+boolean to be applied to every component.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[props](RouteRecordBase.md#props)
+
+___
+
+### redirect
+
+• `Optional` **redirect**: `undefined`
+
+Where to redirect if the route is directly matched. The redirection happens
+before any navigation guard and triggers a new navigation with the new
+target location.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[redirect](RouteRecordBase.md#redirect)
+
+___
+
+### sensitive
+
+• `Optional` **sensitive**: `boolean`
+
+Makes the RegExp case-sensitive.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[sensitive](RouteRecordBase.md#sensitive)
+
+___
+
+### strict
+
+• `Optional` **strict**: `boolean`
+
+Whether to disallow a trailing slash or not.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[strict](RouteRecordBase.md#strict)
diff --git a/packages/docs/zh/api/interfaces/RouteRecordMultipleViewsWithChildren.md b/packages/docs/zh/api/interfaces/RouteRecordMultipleViewsWithChildren.md
new file mode 100644 (file)
index 0000000..6c0a464
--- /dev/null
@@ -0,0 +1,189 @@
+---
+editLink: false
+---
+
+<!-- TODO: translation -->
+
+[API Documentation](../index.md) / RouteRecordMultipleViewsWithChildren
+
+# Interface: RouteRecordMultipleViewsWithChildren
+
+Route Record defining multiple named components with the `components` option and children.
+
+## Hierarchy
+
+- [`_RouteRecordBase`](RouteRecordBase.md)
+
+  ↳ **`RouteRecordMultipleViewsWithChildren`**
+
+## Properties
+
+### alias
+
+• `Optional` **alias**: `string` \| `string`[]
+
+Aliases for the record. Allows defining extra paths that will behave like a
+copy of the record. Allows having paths shorthands like `/users/:id` and
+`/u/:id`. All `alias` and `path` values must share the same params.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[alias](RouteRecordBase.md#alias)
+
+___
+
+### beforeEnter
+
+• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
+
+Before Enter guard specific to this record. Note `beforeEnter` has no
+effect if the record has a `redirect` property.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[beforeEnter](RouteRecordBase.md#beforeEnter)
+
+___
+
+### children
+
+• **children**: [`RouteRecordRaw`](../index.md#RouteRecordRaw)[]
+
+Array of nested routes.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[children](RouteRecordBase.md#children)
+
+___
+
+### component
+
+• `Optional` **component**: `undefined`
+
+___
+
+### components
+
+• `Optional` **components**: ``null`` \| `Record`\<`string`, `RawRouteComponent`\>
+
+Components to display when the URL matches this route. Allow using named views.
+
+___
+
+### end
+
+• `Optional` **end**: `boolean`
+
+Should the RegExp match until the end by appending a `$` to it.
+
+**`Default Value`**
+
+`true`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[end](RouteRecordBase.md#end)
+
+___
+
+### meta
+
+• `Optional` **meta**: [`RouteMeta`](RouteMeta.md)
+
+Arbitrary data attached to the record.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[meta](RouteRecordBase.md#meta)
+
+___
+
+### name
+
+• `Optional` **name**: [`RouteRecordName`](../index.md#RouteRecordName)
+
+Name for the route record. Must be unique.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[name](RouteRecordBase.md#name)
+
+___
+
+### path
+
+• **path**: `string`
+
+Path of the record. Should start with `/` unless the record is the child of
+another record.
+
+**`Example`**
+
+```ts
+`/users/:id` matches `/users/1` as well as `/users/posva`.
+```
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[path](RouteRecordBase.md#path)
+
+___
+
+### props
+
+• `Optional` **props**: `boolean` \| `Record`\<`string`, `_RouteRecordProps`\>
+
+Allow passing down params as props to the component rendered by
+`router-view`. Should be an object with the same keys as `components` or a
+boolean to be applied to every component.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[props](RouteRecordBase.md#props)
+
+___
+
+### redirect
+
+• `Optional` **redirect**: `RouteRecordRedirectOption`
+
+Where to redirect if the route is directly matched. The redirection happens
+before any navigation guard and triggers a new navigation with the new
+target location.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[redirect](RouteRecordBase.md#redirect)
+
+___
+
+### sensitive
+
+• `Optional` **sensitive**: `boolean`
+
+Makes the RegExp case-sensitive.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[sensitive](RouteRecordBase.md#sensitive)
+
+___
+
+### strict
+
+• `Optional` **strict**: `boolean`
+
+Whether to disallow a trailing slash or not.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[strict](RouteRecordBase.md#strict)
index 4ac724ed3c32edce48f3133d7dab7a6b67cd54ec..83384388998eb0cbfb0428439166e63ad155140d 100644 (file)
@@ -26,7 +26,7 @@ ___
 
 ### beforeEnter %{#Properties-beforeEnter}%
 
-• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[]
+• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
 
 被注册的 beforeEnter 守卫
 
@@ -42,15 +42,15 @@ ___
 
 ### components %{#Properties-components}%
 
-• **components**: `undefined` \| ``null`` \| `Record`<`string`, `RawRouteComponent`\>
+• **components**: `undefined` \| ``null`` \| `Record`\<`string`, `RawRouteComponent`\>
 
-{@inheritDoc RouteRecordMultipleViews.components}
+Components to display when the URL matches this route. Allow using named views.
 
 ___
 
 ### instances %{#Properties-instances}%
 
-• **instances**: `Record`<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`<{}, {}, {}, {}, {}, {}, {}, {}, ``false``, `ComponentOptionsBase`<`any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, {}, {}, `string`\>, {}\>\>
+• **instances**: `Record`\<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`\>
 
 <!-- TODO: translation -->
 
@@ -68,7 +68,9 @@ ___
 
 • **meta**: [`RouteMeta`](RouteMeta.md)
 
-{@inheritDoc _RouteRecordBase.meta}
+<!-- TODO: translation -->
+
+Arbitrary data attached to the record.
 
 ___
 
@@ -76,7 +78,9 @@ ___
 
 • **name**: `undefined` \| [`RouteRecordName`](../index.md#routerecordname)
 
-{@inheritDoc _RouteRecordBase.name}
+<!-- TODO: translation -->
+
+Name for the route record. Must be unique.
 
 ___
 
@@ -84,15 +88,19 @@ ___
 
 • **path**: `string`
 
-{@inheritDoc _RouteRecordBase.path}
+<!-- TODO: translation -->
+
+Path of the record. Should start with `/` unless the record is the child of another record.
 
 ___
 
 ### props %{#Properties-props}%
 
-• **props**: `Record`<`string`, `_RouteRecordProps`\>
+• **props**: `Record`\<`string`, `_RouteRecordProps`\>
+
+<!-- TODO: translation -->
 
-{@inheritDoc RouteRecordMultipleViews.props}
+Allow passing down params as props to the component rendered by `router-view`. Should be an object with the same keys as `components` or a boolean to be applied to every component.
 
 ___
 
@@ -100,4 +108,6 @@ ___
 
 • **redirect**: `undefined` \| `RouteRecordRedirectOption`
 
-{@inheritDoc _RouteRecordBase.redirect}
+<!-- TODO: translation -->
+
+Where to redirect if the route is directly matched. The redirection happens before any navigation guard and triggers a new navigation with the new target location.
diff --git a/packages/docs/zh/api/interfaces/RouteRecordRedirect.md b/packages/docs/zh/api/interfaces/RouteRecordRedirect.md
new file mode 100644 (file)
index 0000000..3c50294
--- /dev/null
@@ -0,0 +1,186 @@
+---
+editLink: false
+---
+
+<!-- TODO: translation -->
+
+[API Documentation](../index.md) / RouteRecordRedirect
+
+# Interface: RouteRecordRedirect
+
+Route Record that defines a redirect. Cannot have `component` or `components`
+as it is never rendered.
+
+## Hierarchy
+
+- [`_RouteRecordBase`](RouteRecordBase.md)
+
+  ↳ **`RouteRecordRedirect`**
+
+## Properties
+
+### alias
+
+• `Optional` **alias**: `string` \| `string`[]
+
+Aliases for the record. Allows defining extra paths that will behave like a
+copy of the record. Allows having paths shorthands like `/users/:id` and
+`/u/:id`. All `alias` and `path` values must share the same params.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[alias](RouteRecordBase.md#alias)
+
+___
+
+### beforeEnter
+
+• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
+
+Before Enter guard specific to this record. Note `beforeEnter` has no
+effect if the record has a `redirect` property.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[beforeEnter](RouteRecordBase.md#beforeEnter)
+
+___
+
+### children
+
+• `Optional` **children**: [`RouteRecordRaw`](../index.md#RouteRecordRaw)[]
+
+Array of nested routes.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[children](RouteRecordBase.md#children)
+
+___
+
+### component
+
+• `Optional` **component**: `undefined`
+
+___
+
+### components
+
+• `Optional` **components**: `undefined`
+
+___
+
+### end
+
+• `Optional` **end**: `boolean`
+
+Should the RegExp match until the end by appending a `$` to it.
+
+**`Default Value`**
+
+`true`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[end](RouteRecordBase.md#end)
+
+___
+
+### meta
+
+• `Optional` **meta**: [`RouteMeta`](RouteMeta.md)
+
+Arbitrary data attached to the record.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[meta](RouteRecordBase.md#meta)
+
+___
+
+### name
+
+• `Optional` **name**: [`RouteRecordName`](../index.md#RouteRecordName)
+
+Name for the route record. Must be unique.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[name](RouteRecordBase.md#name)
+
+___
+
+### path
+
+• **path**: `string`
+
+Path of the record. Should start with `/` unless the record is the child of
+another record.
+
+**`Example`**
+
+```ts
+`/users/:id` matches `/users/1` as well as `/users/posva`.
+```
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[path](RouteRecordBase.md#path)
+
+___
+
+### props
+
+• `Optional` **props**: `undefined`
+
+Allow passing down params as props to the component rendered by `router-view`.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[props](RouteRecordBase.md#props)
+
+___
+
+### redirect
+
+• **redirect**: `RouteRecordRedirectOption`
+
+Where to redirect if the route is directly matched. The redirection happens
+before any navigation guard and triggers a new navigation with the new
+target location.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[redirect](RouteRecordBase.md#redirect)
+
+___
+
+### sensitive
+
+• `Optional` **sensitive**: `boolean`
+
+Makes the RegExp case-sensitive.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[sensitive](RouteRecordBase.md#sensitive)
+
+___
+
+### strict
+
+• `Optional` **strict**: `boolean`
+
+Whether to disallow a trailing slash or not.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[strict](RouteRecordBase.md#strict)
diff --git a/packages/docs/zh/api/interfaces/RouteRecordSingleView.md b/packages/docs/zh/api/interfaces/RouteRecordSingleView.md
new file mode 100644 (file)
index 0000000..d498116
--- /dev/null
@@ -0,0 +1,187 @@
+---
+editLink: false
+---
+
+<!-- TODO: translation -->
+
+[API Documentation](../index.md) / RouteRecordSingleView
+
+# Interface: RouteRecordSingleView
+
+Route Record defining one single component with the `component` option.
+
+## Hierarchy
+
+- [`_RouteRecordBase`](RouteRecordBase.md)
+
+  ↳ **`RouteRecordSingleView`**
+
+## Properties
+
+### alias
+
+• `Optional` **alias**: `string` \| `string`[]
+
+Aliases for the record. Allows defining extra paths that will behave like a
+copy of the record. Allows having paths shorthands like `/users/:id` and
+`/u/:id`. All `alias` and `path` values must share the same params.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[alias](RouteRecordBase.md#alias)
+
+___
+
+### beforeEnter
+
+• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
+
+Before Enter guard specific to this record. Note `beforeEnter` has no
+effect if the record has a `redirect` property.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[beforeEnter](RouteRecordBase.md#beforeEnter)
+
+___
+
+### children
+
+• `Optional` **children**: `undefined`
+
+Array of nested routes.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[children](RouteRecordBase.md#children)
+
+___
+
+### component
+
+• **component**: `RawRouteComponent`
+
+Component to display when the URL matches this route.
+
+___
+
+### components
+
+• `Optional` **components**: `undefined`
+
+___
+
+### end
+
+• `Optional` **end**: `boolean`
+
+Should the RegExp match until the end by appending a `$` to it.
+
+**`Default Value`**
+
+`true`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[end](RouteRecordBase.md#end)
+
+___
+
+### meta
+
+• `Optional` **meta**: [`RouteMeta`](RouteMeta.md)
+
+Arbitrary data attached to the record.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[meta](RouteRecordBase.md#meta)
+
+___
+
+### name
+
+• `Optional` **name**: [`RouteRecordName`](../index.md#RouteRecordName)
+
+Name for the route record. Must be unique.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[name](RouteRecordBase.md#name)
+
+___
+
+### path
+
+• **path**: `string`
+
+Path of the record. Should start with `/` unless the record is the child of
+another record.
+
+**`Example`**
+
+```ts
+`/users/:id` matches `/users/1` as well as `/users/posva`.
+```
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[path](RouteRecordBase.md#path)
+
+___
+
+### props
+
+• `Optional` **props**: `_RouteRecordProps`
+
+Allow passing down params as props to the component rendered by `router-view`.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[props](RouteRecordBase.md#props)
+
+___
+
+### redirect
+
+• `Optional` **redirect**: `undefined`
+
+Where to redirect if the route is directly matched. The redirection happens
+before any navigation guard and triggers a new navigation with the new
+target location.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[redirect](RouteRecordBase.md#redirect)
+
+___
+
+### sensitive
+
+• `Optional` **sensitive**: `boolean`
+
+Makes the RegExp case-sensitive.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[sensitive](RouteRecordBase.md#sensitive)
+
+___
+
+### strict
+
+• `Optional` **strict**: `boolean`
+
+Whether to disallow a trailing slash or not.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[strict](RouteRecordBase.md#strict)
diff --git a/packages/docs/zh/api/interfaces/RouteRecordSingleViewWithChildren.md b/packages/docs/zh/api/interfaces/RouteRecordSingleViewWithChildren.md
new file mode 100644 (file)
index 0000000..e9430ee
--- /dev/null
@@ -0,0 +1,187 @@
+---
+editLink: false
+---
+
+<!-- TODO: translation -->
+
+[API Documentation](../index.md) / RouteRecordSingleViewWithChildren
+
+# Interface: RouteRecordSingleViewWithChildren
+
+Route Record defining one single component with a nested view.
+
+## Hierarchy
+
+- [`_RouteRecordBase`](RouteRecordBase.md)
+
+  ↳ **`RouteRecordSingleViewWithChildren`**
+
+## Properties
+
+### alias
+
+• `Optional` **alias**: `string` \| `string`[]
+
+Aliases for the record. Allows defining extra paths that will behave like a
+copy of the record. Allows having paths shorthands like `/users/:id` and
+`/u/:id`. All `alias` and `path` values must share the same params.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[alias](RouteRecordBase.md#alias)
+
+___
+
+### beforeEnter
+
+• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[]
+
+Before Enter guard specific to this record. Note `beforeEnter` has no
+effect if the record has a `redirect` property.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[beforeEnter](RouteRecordBase.md#beforeEnter)
+
+___
+
+### children
+
+• **children**: [`RouteRecordRaw`](../index.md#RouteRecordRaw)[]
+
+Array of nested routes.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[children](RouteRecordBase.md#children)
+
+___
+
+### component
+
+• `Optional` **component**: ``null`` \| `RawRouteComponent`
+
+Component to display when the URL matches this route.
+
+___
+
+### components
+
+• `Optional` **components**: `undefined`
+
+___
+
+### end
+
+• `Optional` **end**: `boolean`
+
+Should the RegExp match until the end by appending a `$` to it.
+
+**`Default Value`**
+
+`true`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[end](RouteRecordBase.md#end)
+
+___
+
+### meta
+
+• `Optional` **meta**: [`RouteMeta`](RouteMeta.md)
+
+Arbitrary data attached to the record.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[meta](RouteRecordBase.md#meta)
+
+___
+
+### name
+
+• `Optional` **name**: [`RouteRecordName`](../index.md#RouteRecordName)
+
+Name for the route record. Must be unique.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[name](RouteRecordBase.md#name)
+
+___
+
+### path
+
+• **path**: `string`
+
+Path of the record. Should start with `/` unless the record is the child of
+another record.
+
+**`Example`**
+
+```ts
+`/users/:id` matches `/users/1` as well as `/users/posva`.
+```
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[path](RouteRecordBase.md#path)
+
+___
+
+### props
+
+• `Optional` **props**: `_RouteRecordProps`
+
+Allow passing down params as props to the component rendered by `router-view`.
+
+#### Overrides
+
+[_RouteRecordBase](RouteRecordBase.md).[props](RouteRecordBase.md#props)
+
+___
+
+### redirect
+
+• `Optional` **redirect**: `RouteRecordRedirectOption`
+
+Where to redirect if the route is directly matched. The redirection happens
+before any navigation guard and triggers a new navigation with the new
+target location.
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[redirect](RouteRecordBase.md#redirect)
+
+___
+
+### sensitive
+
+• `Optional` **sensitive**: `boolean`
+
+Makes the RegExp case-sensitive.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[sensitive](RouteRecordBase.md#sensitive)
+
+___
+
+### strict
+
+• `Optional` **strict**: `boolean`
+
+Whether to disallow a trailing slash or not.
+
+**`Default Value`**
+
+`false`
+
+#### Inherited from
+
+[_RouteRecordBase](RouteRecordBase.md).[strict](RouteRecordBase.md#strict)
\ No newline at end of file
index ae8f773bd49a08cc87d80b5786b433e646f94458..6978460ad4309d51671dcbeff4397f3fa0bcec39 100644 (file)
@@ -14,7 +14,7 @@ editLink: false
 
 ### currentRoute %{#Properties-currentRoute}%
 
-• `只读` **currentRoute**: `Ref`<[`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md)\>
+• `只读` **currentRoute**: `Ref`\<[`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md)\>
 
 当前的 [RouteLocationNormalized](RouteLocationNormalized.md)。
 
@@ -91,16 +91,6 @@ ___
 
 添加一个导航钩子,它会在每次导航之后被执行。返回一个用来移除该钩子的函数。
 
-**`Example`**
-
-```js
-router.afterEach((to, from, failure) => {
-  if (isNavigationFailure(failure)) {
-    console.log('failed navigation', failure)
-  }
-})
-```
-
 #### 参数 %{#Methods-afterEach-Parameters}%
 
 | 名称 | 类型 | 描述 |
@@ -111,6 +101,8 @@ router.afterEach((to, from, failure) => {
 
 `fn`
 
+a function that removes the registered hook
+
 ▸ (): `void`
 
 添加一个导航钩子,它会在每次导航之后被执行。返回一个用来移除该钩子的函数。
@@ -153,7 +145,7 @@ ___
 
 | 名称 | 类型 | 描述 |
 | :------ | :------ | :------ |
-| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> | 要加入的导航钩子 |
+| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> | 要加入的导航钩子 |
 
 #### 返回值 %{#Methods-beforeEach-Returns}%
 
@@ -175,19 +167,11 @@ ___
 
 添加一个导航守卫,它会在导航将要被解析之前被执行。此时所有组件都已经获取完毕,且其它导航守卫也都已经完成调用。返回一个用来移除该守卫的函数。
 
-**`Example`**
-
-```js
-router.beforeResolve(to => {
-  if (to.meta.requiresAuth && !isAuthenticated) return false
-})
-```
-
 #### 参数 %{#Methods-beforeResolve-Parameters}%
 
 | 名称 | 类型 | 描述 |
 | :------ | :------ | :------ |
-| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> | navigation guard to add |
+| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> | navigation guard to add |
 
 #### 返回值 %{#Methods-beforeResolve-Returns}%
 
@@ -273,7 +257,7 @@ ___
 
 ### isReady %{#Methods-isReady}%
 
-▸ **isReady**(): `Promise`<`void`\>
+▸ **isReady**(): `Promise`\<`void`\>
 
 返回一个 Promise,它会在路由器完成初始导航之后被解析,也就是说这时所有和初始路由有关联的异步入口钩子和异步组件都已经被解析。如果初始导航已经发生,则该 Promise 会被立刻解析。
 
@@ -281,7 +265,7 @@ ___
 
 #### 返回值 %{#Methods-isReady-Returns}%
 
-`Promise`<`void`\>
+`Promise`\<`void`\>
 
 ___
 
@@ -295,7 +279,7 @@ ___
 
 | 名称 | 类型 | 描述 |
 | :------ | :------ | :------ |
-| `handler` | `_ErrorHandler` | 要注册的错误处理器 |
+| `handler` | `_ErrorListener` | 要注册的错误处理器 |
 
 #### 返回值 %{#Methods-onError-Returns}%
 
@@ -313,7 +297,7 @@ ___
 
 ### push %{#Methods-push}%
 
-▸ **push**(`to`): `Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
+▸ **push**(`to`): `Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
 
 程序式地通过将一条记录加入到历史栈中来导航到一个新的 URL。
 
@@ -325,7 +309,7 @@ ___
 
 #### 返回值 %{#Methods-push-Returns}%
 
-`Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
+`Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
 
 ___
 
@@ -349,7 +333,7 @@ ___
 
 ### replace %{#Methods-replace}%
 
-▸ **replace**(`to`): `Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
+▸ **replace**(`to`): `Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
 
 程序式地通过替换历史栈中的当前记录来导航到一个新的 URL。
 
@@ -361,7 +345,7 @@ ___
 
 #### 返回值 %{#Methods-replace-Returns}%
 
-`Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
+`Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\>
 
 ___
 
index 8f94710d8fcb4aa7e05f55b4fcdc65930fdff1bf..ec557c818e4af9b7ca80bca5d4718b69011c02e3 100644 (file)
@@ -70,13 +70,6 @@ ___
 
 按指定方向访问历史。
 
-**`Example`**
-
-```js
-myHistory.go(-1) // equivalent to window.history.back()
-myHistory.go(1) // equivalent to window.history.forward()
-```
-
 #### 参数 %{#Methods-go-Parameters}%
 
 | 名称 | 类型 | 描述 |
@@ -88,6 +81,13 @@ myHistory.go(1) // equivalent to window.history.forward()
 
 `void`
 
+**`Example`**
+
+```js
+myHistory.go(-1) // equivalent to window.history.back()
+myHistory.go(1) // equivalent to window.history.forward()
+```
+
 ___
 
 ### listen %{#Methods-listen}%
@@ -143,7 +143,7 @@ ___
 
 ▸ **replace**(`to`, `data?`): `void`
 
-和 [push](RouterHistory.md#push) 相同,只是执行了 `history.replaceState`
+和 [RouterHistory.push](RouterHistory.md#push) 相同,只是执行了 `history.replaceState`
 以换掉 `history.pushState`。
 
 #### 参数 %{#Methods-replace-Parameters}%
index a713881aaa2ddf3ac3c4f0873c1a31f681da9e1c..0f0229f5932698f75ae082a0af5986727d905ea5 100644 (file)
@@ -73,7 +73,17 @@ ___
 
 ▸ (`search`): [`LocationQuery`](../index.md#locationquery)
 
-解析查询的自定义实现。请查阅其相关内容 [stringifyQuery](RouterOptions.md#stringifyquery)。
+解析查询的自定义实现。请查阅其相关内容 [RouterOptions.stringifyQuery](RouterOptions.md#stringifyquery)。
+
+##### 参数 %{#Properties-parseQuery-Type-declaration-Parameters}%
+
+| 名称 | 类型 |
+| :------ | :------ |
+| `search` | `string` |
+
+##### 返回值 %{#Properties-parseQuery-Type-declaration-Returns}%
+
+[`LocationQuery`](../index.md#locationquery)
 
 **`示例`**
 
@@ -89,16 +99,6 @@ createRouter({
 })
 ```
 
-##### 参数 %{#Properties-parseQuery-Type-declaration-Parameters}%
-
-| 名称 | 类型 |
-| :------ | :------ |
-| `search` | `string` |
-
-##### 返回值 %{#Properties-parseQuery-Type-declaration-Returns}%
-
-[`LocationQuery`](../index.md#locationquery)
-
 ___
 
 ### routes %{#Properties-routes}%
index c0eb1742b709f5c68730fa15d9042d76f95afb83..4092cee43c6b8b99e2c0ee43f375bab33fd94bee 100644 (file)
@@ -6,11 +6,15 @@ editLink: false
 
 # 接口:RouterScrollBehavior
 
+<!-- TODO: translation -->
+
+Type of the `scrollBehavior` option that can be passed to `createRouter`.
+
 ## 可调用函数 %{#Callable}%
 
 ### RouterScrollBehavior %{#Callable-RouterScrollBehavior}%
 
-▸ **RouterScrollBehavior**(`to`, `from`, `savedPosition`): `Awaitable`<``false`` \| `void` \| `ScrollPosition`\>
+▸ **RouterScrollBehavior**(`to`, `from`, `savedPosition`): `Awaitable`\<``false`` \| `void` \| `ScrollPosition`\>
 
 #### 参数 %{#Callable-RouterScrollBehavior-Parameters}%
 
@@ -22,4 +26,4 @@ editLink: false
 
 #### 返回值 %{#Callable-RouterScrollBehavior-Returns}%
 
-`Awaitable`<``false`` \| `void` \| `ScrollPosition`\>
+`Awaitable`\<``false`` \| `void` \| `ScrollPosition`\>
index 5ad3bcace34af891b325fc0cf27146bba56a6b23..380b7f22afe7b0daf21db4640f12925995fbdfdd 100644 (file)
@@ -5,7 +5,7 @@
   title="Learn how to add routes at runtime"
 />
 
-对路由的添加通常是通过 [`routes` 选项](../../api/#routes)来完成的,但是在某些情况下,你可能想在应用程序已经运行的时候添加或删除路由。具有可扩展接口(如 [Vue CLI UI](https://cli.vuejs.org/dev-guide/ui-api.html) )这样的应用程序可以使用它来扩展应用程序。
+对路由的添加通常是通过 `routes` 选项来完成的,但是在某些情况下,你可能想在应用程序已经运行的时候添加或删除路由。具有可扩展接口(如 [Vue CLI UI](https://cli.vuejs.org/dev-guide/ui-api.html) )这样的应用程序可以使用它来扩展应用程序。
 
 ## 添加路由
 
index c4e0dffdf44d6db0b7cd67b801ba81bc8bc0423a..80e2829d29caf3fbcc8838bdb3b2ecaefe9f1ff9 100644 (file)
@@ -17,7 +17,11 @@ const UserDetails = () => import('./views/UserDetails.vue')
 
 const router = createRouter({
   // ...
-  routes: [{ path: '/users/:id', component: UserDetails }],
+  routes: [
+    { path: '/users/:id', component: UserDetails }
+    // 或在路由定义里直接使用它
+    { path: '/users/:id', component: () => import('./views/UserDetails.vue') },
+  ],
 })
 ```
 
index a2a53094b9715c45b84b805e11bc85e622ce6c7d..84f909725648415fb293abd769999b158d51e85d 100644 (file)
@@ -17,13 +17,13 @@ const routes = [
         path: 'new',
         component: PostsNew,
         // 只有经过身份验证的用户才能创建帖子
-        meta: { requiresAuth: true }
+        meta: { requiresAuth: true },
       },
       {
         path: ':id',
         component: PostsDetail
         // 任何人都可以阅读文章
-        meta: { requiresAuth: false }
+        meta: { requiresAuth: false },
       }
     ]
   }
@@ -58,12 +58,19 @@ router.beforeEach((to, from) => {
 
 ## TypeScript
 
-可以通过扩展 `RouteMeta` 接口来输入 meta 字段:
+<!-- TODO: translation -->
+
+It is possible to type the meta field by extending the `RouteMeta` interface from `vue-router`:
 
 ```ts
-// typings.d.ts or router.ts
+// This can be directly added to any of your `.ts` files like `router.ts`
+// It can also be added to a `.d.ts` file. Make sure it's included in
+// project's tsconfig.json "files"
 import 'vue-router'
 
+// To ensure it is treated as a module, add at least one `export` statement
+export {}
+
 declare module 'vue-router' {
   interface RouteMeta {
     // 是可选的
index c9cb90da73e1862679a38dec0e2b8342a59e3406..b1bfe9d378f3ad3494160107bf9b8bd01804f429 100644 (file)
@@ -62,6 +62,20 @@ if (isNavigationFailure(failure, NavigationFailureType.aborted)) {
 如果你忽略第二个参数: `isNavigationFailure(failure)`,那么就只会检查这个 `failure` 是不是一个 _Navigation Failure_。
 :::
 
+<!-- TODO: translation -->
+
+## Global navigation failures
+
+You can detect global navigation failures globally by using the [`router.afterEach()` navigation guard](./navigation-guards.md#Global-After-Hooks):
+
+```ts
+router.afterEach((to, from, failure) => {
+  if (failure) {
+    sendToAnalytics(to, from, failure)
+  }
+})
+```
+
 ## 鉴别导航故障
 
 正如我们在一开始所说的,有不同的情况会导致导航的中止,所有这些情况都会导致不同的 _Navigation Failure_。它们可以用 `isNavigationFailure` 和 `NavigationFailureType` 来区分。总共有三种不同的类型:
index 3f56595d29b3352f0af4c67a41d7c04f30fb71d6..625e1d7e721f8a50fcef02e1ff422b0c8a39adbb 100644 (file)
@@ -31,7 +31,7 @@ router.beforeEach((to, from) => {
 可以返回的值如下:
 
 - `false`: 取消当前的导航。如果浏览器的 URL 改变了(可能是用户手动或者浏览器后退按钮),那么 URL 地址会重置到 `from` 路由对应的地址。
-- 一个[路由地址](../../api/#routelocationraw): 通过一个路由地址重定向到一个不同的地址,如同调用 [`router.push()`](../../api/#push),且可以传入诸如 `replace: true` 或 `name: 'home'` 之类的选项。它会中断当前的导航,同时用相同的 `from` 创建一个新导航。
+- 一个[路由地址](../../api/#routelocationraw): 通过一个路由地址重定向到一个不同的地址,如同调用 `router.push()`,且可以传入诸如 `replace: true` 或 `name: 'home'` 之类的选项。它会中断当前的导航,同时用相同的 `from` 创建一个新导航。
 
  ```js
   router.beforeEach(async (to, from) => {
@@ -47,7 +47,7 @@ router.beforeEach((to, from) => {
   })
 ```
 
-如果遇到了意料之外的情况,可能会抛出一个 `Error`。这会取消导航并且调用 [`router.onError()`](../../api/#onerror) 注册过的回调。
+如果遇到了意料之外的情况,可能会抛出一个 `Error`。这会取消导航并且调用 [`router.onError()`](../../api/interfaces/Router.md#onError) 注册过的回调。
 
 如果什么都没有,`undefined` 或返回 `true`,**则导航是有效的**,并调用下一个导航守卫
 
@@ -134,6 +134,26 @@ router.afterEach((to, from, failure) => {
 
 了解更多关于 navigation failures 的信息在[它的指南](./navigation-failures.md)中。
 
+<!-- TODO: translation -->
+
+## Global injections within guards
+
+Since Vue 3.3, it is possible to use `inject()` within navigation guards. This is useful for injecting global properties like the [pinia stores](https://pinia.vuejs.org). Anything that is provided with `app.provide()` is also accessible within `router.beforeEach()`, `router.beforeResolve()`, `router.afterEach()`:
+
+```ts
+// main.ts
+const app = createApp(App)
+app.provide('global', 'hello injections')
+
+// router.ts or main.ts
+router.beforeEach((to, from) => {
+  const global = inject('global') // 'hello injections'
+  // a pinia store
+  const userStore = useAuthStore()
+  // ...
+})
+```
+
 ## 路由独享的守卫
 
 你可以直接在路由配置上定义 `beforeEnter` 守卫:
@@ -179,7 +199,7 @@ const routes = [
 ]
 ```
 
-请注意,你也可以通过使用[路径 meta 字段](./meta.md)和[全局导航守卫](#global-before-guards)来实现类似的行为。
+请注意,你也可以通过使用[路径 meta 字段](./meta.md)和全局导航守卫来实现类似的行为。
 
 ## 组件内的守卫
 
diff --git a/packages/docs/zh/guide/advanced/router-view-slot.md b/packages/docs/zh/guide/advanced/router-view-slot.md
new file mode 100644 (file)
index 0000000..49b7d57
--- /dev/null
@@ -0,0 +1,75 @@
+<!-- TODO: translation -->
+
+# RouterView slot
+
+The RouterView component exposes a slot that can be used to render the route component:
+
+```vue-html
+<router-view v-slot="{ Component }">
+  <component :is="Component" />
+</router-view>
+```
+
+The code above is equivalent to using `<router-view />` without the slot, but the slot provides extra flexibility when we want to work with other features.
+
+## KeepAlive & Transition
+
+When working with the [KeepAlive](https://vuejs.org/guide/built-ins/keep-alive.html) component, we would usually want it to keep the route components alive, not the RouterView itself. We can achieve that by putting the KeepAlive inside the slot:
+
+```vue-html
+<router-view v-slot="{ Component }">
+  <keep-alive>
+    <component :is="Component" />
+  </keep-alive>
+</router-view>
+```
+
+Similarly, the slot allows us to use a [Transition](https://vuejs.org/guide/built-ins/transition.html) component to transition between route components:
+
+```vue-html
+<router-view v-slot="{ Component }">
+  <transition>
+    <component :is="Component" />
+  </transition>
+</router-view>
+```
+
+We can also use KeepAlive inside a Transition:
+
+```vue-html
+<router-view v-slot="{ Component }">
+  <transition>
+    <keep-alive>
+      <component :is="Component" />
+    </keep-alive>
+  </transition>
+</router-view>
+```
+
+For more information about using RouterView with the Transition component, see the [Transitions](./transitions) guide.
+
+## Passing props and slots
+
+We can use the slot to pass props or slots to the route component:
+
+```vue-html
+<router-view v-slot="{ Component }">
+  <component :is="Component" some-prop="a value">
+    <p>Some slotted content</p>
+  </component>
+</router-view>
+```
+
+In practice, this usually isn't something you would want to do, as the route components would **all need to use the same props and slots**. See [Passing Props to Route Components](../essentials/passing-props) for other ways to pass props.
+
+## Template refs
+
+Using the slot allows us to put a [template ref](https://vuejs.org/guide/essentials/template-refs.html) directly on the route component:
+
+```vue-html
+<router-view v-slot="{ Component }">
+  <component :is="Component" ref="mainContent" />
+</router-view>
+```
+
+If we put the ref on the `<router-view>` instead then the ref would be populated with the RouterView instance, rather than the route component.
index c34d043dbbe444869763e1e26f94cd0c8ff3000a..f0d77b19acaae69d13b2c0a14dd429c733e65fdb 100644 (file)
@@ -43,7 +43,8 @@ const router = createRouter({
       // 也可以这么写
       // el: document.getElementById('main'),
       el: '#main',
-      top: -10,
+      // 在元素上 10 像素
+      top: 10,
     }
   },
 })
index cc10eebcc19e9525b940caac3f3ab577ebce0fd2..aaabd9e396f2e65ad1ed6cbea3bc6272315992f6 100644 (file)
@@ -5,9 +5,9 @@
   title="Learn about route transitions"
 />
 
-想要在你的路径组件上使用转场,并对导航进行动画处理,你需要使用 [v-slot API](/guide/advanced/composition-api#uselink):
+想要在你的路径组件上使用转场,并对导航进行动画处理,你需要使用 [`<RouterView>` 插槽](./router-view-slot):
 
-```vue-html
+```html
 <router-view v-slot="{ Component }">
   <transition name="fade">
     <component :is="Component" />
@@ -36,7 +36,7 @@ const routes = [
 ]
 ```
 
-```vue-html
+```html
 <router-view v-slot="{ Component, route }">
   <!-- 使用任何自定义过渡和回退到 `fade` -->
   <transition :name="route.meta.transition || 'fade'">
@@ -49,7 +49,7 @@ const routes = [
 
 也可以根据目标路由和当前路由之间的关系,动态地确定使用的过渡。使用和刚才非常相似的片段:
 
-```vue-html
+```html
 <!-- 使用动态过渡名称 -->
 <router-view v-slot="{ Component, route }">
   <transition :name="route.meta.transition">
index edc44085cdf967d86a892b24887cbd3d0fd9cce4..888cb68cb398b49e61840f7f2399675d59f8a5de 100644 (file)
@@ -24,6 +24,24 @@ const router = createRouter({
 
 它在内部传递的实际 URL 之前使用了一个哈希字符(`#`)。由于这部分 URL 从未被发送到服务器,所以它不需要在服务器层面上进行任何特殊处理。不过,**它在 SEO 中确实有不好的影响**。如果你担心这个问题,可以使用 HTML5 模式。
 
+<!-- TODO: translation -->
+
+## Memory mode
+
+The memory history mode doesn't assume a browser environment and therefore doesn't interact with the URL **nor automatically triggers the initial navigation**. This makes it perfect for Node environment and SSR. It is created with `createMemoryHistory()` and **requires you to push the initial navigation** after calling `app.use(router)`.
+
+```js
+import { createRouter, createMemoryHistory } from 'vue-router'
+const router = createRouter({
+  history: createMemoryHistory(),
+  routes: [
+    //...
+  ],
+})
+```
+
+While it's not recommended, you can use this mode inside Browser applications but note **there will be no history**, meaning you won't be able to go _back_ or _forward_.
+
 ## HTML5 模式
 
 用 `createWebHistory()` 创建 HTML5 模式,推荐使用这个模式:
@@ -66,7 +84,7 @@ const router = createRouter({
 </IfModule>
 ```
 
-也可以使用 [`FallbackResource`](https://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource) 代替 `mod_rewrite`。
+也可以使用 [`FallbackResource`](https://httpd.apache.org/docs/2.4/mod/mod_dir.html#fallbackresource) 代替 `mod_rewrite`。
 
 ### nginx
 
index 4541f37009430190840c31d5e8312c05c60a95a5..81bb0b60f431866d9a60f37bf80ac9205c47effb 100644 (file)
@@ -24,7 +24,7 @@ const routes = [
 
 要链接到一个命名的路由,可以向 `router-link` 组件的 `to` 属性传递一个对象:
 
-```vue-html
+```html
 <router-link :to="{ name: 'user', params: { username: 'erina' }}">
   User
 </router-link>
@@ -39,3 +39,7 @@ router.push({ name: 'user', params: { username: 'erina' } })
 在这两种情况下,路由将导航到路径 `/user/erina`。
 
 完整的例子在[这里](https://github.com/vuejs/vue-router/blob/dev/examples/named-routes/app.js).
+
+<!-- TODO: translation -->
+
+Each name **must be unique** across all routes. If you add the same name to multiple routes, the router will only keep the last one. You can read more about this [in the Dynamic Routing](../advanced/dynamic-routing.md#Removing-routes) section.
index e87f9eb2534b643a99f28bc8a1e36fb70f6a210d..11e8f5f180b84f4d5af7666c4a0c8a645bd52ff6 100644 (file)
@@ -7,7 +7,7 @@
 
 有时候想同时 (同级) 展示多个视图,而不是嵌套展示,例如创建一个布局,有 `sidebar` (侧导航) 和 `main` (主内容) 两个视图,这个时候命名视图就派上用场了。你可以在界面中拥有多个单独命名的视图,而不是只有一个单独的出口。如果 `router-view` 没有设置名字,那么默认为 `default`。
 
-```vue-html
+```html
 <router-view class="view left-sidebar" name="LeftSidebar"></router-view>
 <router-view class="view main-content"></router-view>
 <router-view class="view right-sidebar" name="RightSidebar"></router-view>
@@ -59,7 +59,7 @@ const router = createRouter({
 
 `UserSettings` 组件的 `<template>` 部分应该是类似下面的这段代码:
 
-```vue-html
+```html
 <!-- UserSettings.vue -->
 <div>
   <h1>User Settings</h1>
index 82b1520c04f4715aa5c2fb1b94b2101c1f12117b..923519e3b7b69df5abed7942a5e640654fdf10c2 100644 (file)
@@ -13,7 +13,9 @@ sidebarDepth: 0
 
 ## 导航到不同的位置
 
-**注意:在 Vue 实例中,你可以通过 `$router` 访问路由实例。因此你可以调用 `this.$router.push`。**
+<!-- TODO: translation -->
+<!-- **注意:在 Vue 实例中,你可以通过 `$router` 访问路由实例。因此你可以调用 `this.$router.push`。** -->
+**Note: The examples below refer to the router instance as `router`. Inside a component, you can access the router using the `$router` property, e.g. `this.$router.push(...)`. If you're using the Composition API, the router is accessible by calling [`useRouter()`](../advanced/composition-api).**
 
 想要导航到不同的 URL,可以使用 `router.push` 方法。这个方法会向 history 栈添加一个新的记录,所以,当用户点击浏览器后退按钮时,会回到之前的 URL。
 
@@ -56,7 +58,7 @@ router.push({ name: 'user', params: { username } }) // -> /user/eduardo
 router.push({ path: '/user', params: { username } }) // -> /user
 ```
 
-当指定 `params` 时,可提供 `string` 或 `number` 参数(或者对于[可重复的参数](./route-matching-syntax.md#repeatable-params)可提供一个数组)。**任何其他类型(如 `undefined`、`false` 等)都将被自动字符串化**。对于[可选参数](./route-matching-syntax.md#repeatable-params),你可以提供一个空字符串(`""`)来跳过它。
+当指定 `params` 时,可提供 `string` 或 `number` 参数(或者对于[可重复的参数](./route-matching-syntax.md#repeatable-params)可提供一个数组)。**任何其他类型(如对象、布尔等)都将被自动字符串化**。对于[可选参数](./route-matching-syntax.md#repeatable-params),你可以提供一个空字符串(`""`)或 `null` 来移除它。
 
 由于属性 `to` 与 `router.push` 接受的对象种类相同,所以两者的规则完全相同。
 
@@ -70,7 +72,7 @@ router.push({ path: '/user', params: { username } }) // -> /user
 | --------------------------------- | --------------------- |
 | `<router-link :to="..." replace>` | `router.replace(...)` |
 
-也可以直接在传递给 `router.push` 的 `routeLocation` 中增加一个属性 `replace: true` :
+也可以直接在传递给 `router.push` 的 `to` 参数中增加一个属性 `replace: true` :
 
 ```js
 router.push({ path: '/home', replace: true })
@@ -110,4 +112,4 @@ router.go(100)
 
 因此,如果你已经熟悉 [Browser History APIs](https://developer.mozilla.org/en-US/docs/Web/API/History_API),在使用 Vue Router 时,操作历史记录就会觉得很熟悉。
 
-值得一提的是,无论在创建路由器实例时传递什么样的 [`history` 配置](../../api/#history),Vue Router 的导航方法( `push`、`replace`、`go` )都能始终正常工作。
+值得一提的是,无论在创建路由器实例时传递什么 `history` 配置,Vue Router 的导航方法 (`push`、`replace`、`go`) 都能始终正常工作。
index 0cef8761a2d80fb28b9d7e496d0d4daf23dd645c..c59b0b22bd17629209bd27ff5f1c34ba52c2575b 100644 (file)
@@ -78,3 +78,22 @@ const routes = [
 URL `/search?q=vue` 将传递 `{query: 'vue'}` 作为 props 传给 `SearchUser` 组件。
 
 请尽可能保持 `props` 函数为无状态的,因为它只会在路由发生变化时起作用。如果你需要状态来定义 props,请使用包装组件,这样 vue 才可以对状态变化做出反应。
+
+<!-- TODO: translation -->
+
+## Via RouterView
+
+You can also pass any props via the [`<RouterView>` slot](../advanced/router-view-slot):
+
+```vue-html
+<RouterView v-slot="{ Component }">
+  <component
+    :is="Component"
+    view-prop="value"
+   />
+</RouterView>
+```
+
+::: warning
+In this case, **all view components** will receive `view-prop`. This is usually not a good idea as  it means that all of the view components have declared a `view-prop` prop, which is not necessarily true. If possible, use any of the options above.
+:::
index ee2a039663502cd16bc4fa51e3f90483bfffc57a..833ff30286f6659ddf1dc4c0c0aa3337cceaeaf4 100644 (file)
@@ -34,7 +34,7 @@
 
 ### `router-view`
 
-`router-view` 将显示与 url 对应的组件。你可以把它放在任何地方,以适应你的布局。
+`router-view` 将显示与 URL 对应的组件。你可以把它放在任何地方,以适应你的布局。
 
 ## JavaScript
 
index f0e8766b7c9e44f42eaddf53c1b4717891b98545..a5deb8156da5a2fe04c995d6df719160806b8a3b 100644 (file)
@@ -113,6 +113,21 @@ router.resolve({
 
 **原因**:Vue Router 不再使用 `path-to-regexp`,而是实现了自己的解析系统,允许路由排序并实现动态路由。由于我们通常在每个项目中只添加一个通配符路由,所以支持 `*` 的特殊语法并没有太大的好处。参数的编码是跨路由的,无一例外,让事情更容易预测。
 
+<!-- TODO: translation -->
+
+### The `currentRoute` property is now a `ref()`
+
+Previously the properties of the [`currentRoute`](https://v3.router.vuejs.org/api/#router-currentroute) object on a router instance could be accessed directly.
+
+With the introduction of vue-router v4, the underlying type of the `currentRoute` object on the router instance has changed to `Ref<RouteLocationNormalizedLoaded>`, which comes from the newer [reactivity fundamentals](https://vuejs.org/guide/essentials/reactivity-fundamentals.html) introduced in Vue 3.
+
+While this doesn't change anything if you're reading the route with `useRoute()` or `this.$route`, if you're accessing it directly on the router instance, you will need to access the actual route object via `currentRoute.value`:
+
+```ts
+const { page } = router.currentRoute.query // [!code --]
+const { page } = router.currentRoute.value.query // [!code ++]
+```
+
 ### 将 `onReady` 改为 `isReady`
 
 现有的 `router.onReady()` 函数已被 `router.isReady()` 取代,该函数不接受任何参数并返回一个 Promise:
index a3058e9c91ac8a6ea8fe2138157b952d50571c69..58160059b428ec8265330626b9c4a8cb5f24ddc9 100644 (file)
 
 <!--/email_off-->
 
-## npm
+<!-- TODO: translation -->
 
-```bash
+This will expose Vue Router via a global `VueRouter` object, e.g. `VueRouter.createRouter(...)`.
+
+## Package managers
+
+If you have an existing project that uses a JavaScript package manager, you can install Vue Router from the npm registry:
+
+::: code-group
+
+```bash [npm]
 npm install vue-router@4
 ```
 
-## yarn
-
-```bash
+```bash [yarn]
 yarn add vue-router@4
-```
\ No newline at end of file
+```
+
+```bash [pnpm]
+pnpm add vue-router@4
+```
+
+:::
+
+If you're starting a new project, you might find it easier to use the [create-vue](https://github.com/vuejs/create-vue) scaffolding tool, which creates a Vite-based project with the option to include Vue Router:
+
+::: code-group
+
+```bash [npm]
+npm create vue@latest
+```
+
+```bash [yarn]
+yarn create vue
+```
+
+```bash [pnpm]
+pnpm create vue
+```
+
+:::
+
+You'll be prompted with some questions about the kind of project you want to create. If you choose to install Vue Router, the example application will also demonstrate some of Vue Router's core features.
+
+Projects using package managers will typically use ES modules to access Vue Router, e.g. `import { createRouter } from 'vue-router'`.