From 110c86929ac92e2428d8d4958b6c6374754bc0df Mon Sep 17 00:00:00 2001 From: Jinjiang Date: Thu, 21 Dec 2023 00:44:44 +0800 Subject: [PATCH] docs(zh): sync update to 35a9c1b (#2084) --- packages/docs/.vitepress/config/zh.ts | 8 + .../docs/.vitepress/translation-status.json | 6 +- packages/docs/zh/api/index.md | 92 +++++---- .../docs/zh/api/interfaces/NavigationGuard.md | 8 +- .../api/interfaces/NavigationGuardWithThis.md | 10 +- .../zh/api/interfaces/RouteLocationMatched.md | 28 ++- .../api/interfaces/RouteLocationNormalized.md | 2 +- packages/docs/zh/api/interfaces/RouteMeta.md | 2 +- .../docs/zh/api/interfaces/RouteRecordBase.md | 151 ++++++++++++++ .../interfaces/RouteRecordMultipleViews.md | 189 ++++++++++++++++++ .../RouteRecordMultipleViewsWithChildren.md | 189 ++++++++++++++++++ .../api/interfaces/RouteRecordNormalized.md | 30 ++- .../zh/api/interfaces/RouteRecordRedirect.md | 186 +++++++++++++++++ .../api/interfaces/RouteRecordSingleView.md | 187 +++++++++++++++++ .../RouteRecordSingleViewWithChildren.md | 187 +++++++++++++++++ packages/docs/zh/api/interfaces/Router.md | 40 ++-- .../docs/zh/api/interfaces/RouterHistory.md | 16 +- .../docs/zh/api/interfaces/RouterOptions.md | 22 +- .../zh/api/interfaces/RouterScrollBehavior.md | 8 +- .../docs/zh/guide/advanced/dynamic-routing.md | 2 +- .../docs/zh/guide/advanced/lazy-loading.md | 6 +- packages/docs/zh/guide/advanced/meta.md | 15 +- .../zh/guide/advanced/navigation-failures.md | 14 ++ .../zh/guide/advanced/navigation-guards.md | 26 ++- .../zh/guide/advanced/router-view-slot.md | 75 +++++++ .../docs/zh/guide/advanced/scroll-behavior.md | 3 +- .../docs/zh/guide/advanced/transitions.md | 8 +- .../docs/zh/guide/essentials/history-mode.md | 20 +- .../docs/zh/guide/essentials/named-routes.md | 6 +- .../docs/zh/guide/essentials/named-views.md | 4 +- .../docs/zh/guide/essentials/navigation.md | 10 +- .../docs/zh/guide/essentials/passing-props.md | 19 ++ packages/docs/zh/guide/index.md | 2 +- packages/docs/zh/guide/migration/index.md | 15 ++ packages/docs/zh/installation.md | 46 ++++- 35 files changed, 1483 insertions(+), 149 deletions(-) create mode 100644 packages/docs/zh/api/interfaces/RouteRecordBase.md create mode 100644 packages/docs/zh/api/interfaces/RouteRecordMultipleViews.md create mode 100644 packages/docs/zh/api/interfaces/RouteRecordMultipleViewsWithChildren.md create mode 100644 packages/docs/zh/api/interfaces/RouteRecordRedirect.md create mode 100644 packages/docs/zh/api/interfaces/RouteRecordSingleView.md create mode 100644 packages/docs/zh/api/interfaces/RouteRecordSingleViewWithChildren.md create mode 100644 packages/docs/zh/guide/advanced/router-view-slot.md diff --git a/packages/docs/.vitepress/config/zh.ts b/packages/docs/.vitepress/config/zh.ts index 0776b666..83068e02 100644 --- a/packages/docs/.vitepress/config/zh.ts +++ b/packages/docs/.vitepress/config/zh.ts @@ -48,6 +48,10 @@ export const zhConfig: LocaleSpecificConfig = { 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 = { 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', diff --git a/packages/docs/.vitepress/translation-status.json b/packages/docs/.vitepress/translation-status.json index 1a210127..ea46a912 100644 --- a/packages/docs/.vitepress/translation-status.json +++ b/packages/docs/.vitepress/translation-status.json @@ -1,6 +1,6 @@ { "zh": { - "hash": "1a3a28f", - "date": "2023-04-08" + "hash": "35a9c1b", + "date": "2023-12-16" } -} +} \ No newline at end of file diff --git a/packages/docs/zh/api/index.md b/packages/docs/zh/api/index.md index 63efd7c2..3d1183ae 100644 --- a/packages/docs/zh/api/index.md +++ b/packages/docs/zh/api/index.md @@ -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` 中有一个 `` 标签,它的值会因此被忽略,**但注意它会影响所有 history.pushState() 的调用**,这意味着如果你使用一个 `` 标签,它的 `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` 中有一个 `` 标签,它的值会因此被忽略,**但注意它会影响所有 history.pushState() 的调用**,这意味着如果你使用一个 `` 标签,它的 `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 传递给 ``。 @@ -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` | -| `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` }\> | ___ diff --git a/packages/docs/zh/api/interfaces/NavigationGuard.md b/packages/docs/zh/api/interfaces/NavigationGuard.md index 10c1d0ae..52a86b69 100644 --- a/packages/docs/zh/api/interfaces/NavigationGuard.md +++ b/packages/docs/zh/api/interfaces/NavigationGuard.md @@ -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`\> diff --git a/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md b/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md index dc89efa7..1a82c2d6 100644 --- a/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md +++ b/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md @@ -4,7 +4,9 @@ editLink: false [API 参考](../index.md) / NavigationGuardWithThis -# 接口:NavigationGuardWithThis %{#interface-navigationguardwiththis-t}% +# 接口:NavigationGuardWithThis\ %{#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`\> diff --git a/packages/docs/zh/api/interfaces/RouteLocationMatched.md b/packages/docs/zh/api/interfaces/RouteLocationMatched.md index 3b8d0898..ea52970a 100644 --- a/packages/docs/zh/api/interfaces/RouteLocationMatched.md +++ b/packages/docs/zh/api/interfaces/RouteLocationMatched.md @@ -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`\> @@ -82,7 +82,9 @@ ___ • **meta**: [`RouteMeta`](RouteMeta.md) -{@inheritDoc _RouteRecordBase.meta} + + +Arbitrary data attached to the record. #### 继承自 %{#Properties-meta-Inherited-from}% @@ -94,7 +96,9 @@ ___ • **name**: `undefined` \| [`RouteRecordName`](../index.md#routerecordname) -{@inheritDoc _RouteRecordBase.name} + + +Name for the route record. Must be unique. #### 继承自 %{#Properties-name-Inherited-from}% @@ -106,7 +110,9 @@ ___ • **path**: `string` -{@inheritDoc _RouteRecordBase.path} + + +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`\> + + -{@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} + + +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}% diff --git a/packages/docs/zh/api/interfaces/RouteLocationNormalized.md b/packages/docs/zh/api/interfaces/RouteLocationNormalized.md index 820dc7e5..b0ae66d6 100644 --- a/packages/docs/zh/api/interfaces/RouteLocationNormalized.md +++ b/packages/docs/zh/api/interfaces/RouteLocationNormalized.md @@ -6,7 +6,7 @@ editLink: false # 接口:RouteLocationNormalized -和 [RouteLocation](RouteLocation.md) 类似但是其 [matched](RouteLocationNormalized.md#matched) 无法包含重定向的记录 +和 [RouteLocation](RouteLocation.md) 类似但是其 [RouteLocationNormalized.matched](RouteLocationNormalized.md#matched) 无法包含重定向的记录 ## 继承关系 %{#Hierarchy}% diff --git a/packages/docs/zh/api/interfaces/RouteMeta.md b/packages/docs/zh/api/interfaces/RouteMeta.md index d7fdb4c0..0e3ad613 100644 --- a/packages/docs/zh/api/interfaces/RouteMeta.md +++ b/packages/docs/zh/api/interfaces/RouteMeta.md @@ -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 index 00000000..0958b0d1 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordBase.md @@ -0,0 +1,151 @@ +--- +editLink: false +--- + + + +[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 index 00000000..c18ffd14 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordMultipleViews.md @@ -0,0 +1,189 @@ +--- +editLink: false +--- + + + +[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 index 00000000..6c0a464c --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordMultipleViewsWithChildren.md @@ -0,0 +1,189 @@ +--- +editLink: false +--- + + + +[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) diff --git a/packages/docs/zh/api/interfaces/RouteRecordNormalized.md b/packages/docs/zh/api/interfaces/RouteRecordNormalized.md index 4ac724ed..83384388 100644 --- a/packages/docs/zh/api/interfaces/RouteRecordNormalized.md +++ b/packages/docs/zh/api/interfaces/RouteRecordNormalized.md @@ -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`\> @@ -68,7 +68,9 @@ ___ • **meta**: [`RouteMeta`](RouteMeta.md) -{@inheritDoc _RouteRecordBase.meta} + + +Arbitrary data attached to the record. ___ @@ -76,7 +78,9 @@ ___ • **name**: `undefined` \| [`RouteRecordName`](../index.md#routerecordname) -{@inheritDoc _RouteRecordBase.name} + + +Name for the route record. Must be unique. ___ @@ -84,15 +88,19 @@ ___ • **path**: `string` -{@inheritDoc _RouteRecordBase.path} + + +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`\> + + -{@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} + + +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 index 00000000..3c502948 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordRedirect.md @@ -0,0 +1,186 @@ +--- +editLink: false +--- + + + +[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 index 00000000..d498116d --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordSingleView.md @@ -0,0 +1,187 @@ +--- +editLink: false +--- + + + +[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 index 00000000..e9430ee6 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordSingleViewWithChildren.md @@ -0,0 +1,187 @@ +--- +editLink: false +--- + + + +[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 diff --git a/packages/docs/zh/api/interfaces/Router.md b/packages/docs/zh/api/interfaces/Router.md index ae8f773b..6978460a 100644 --- a/packages/docs/zh/api/interfaces/Router.md +++ b/packages/docs/zh/api/interfaces/Router.md @@ -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)\> ___ diff --git a/packages/docs/zh/api/interfaces/RouterHistory.md b/packages/docs/zh/api/interfaces/RouterHistory.md index 8f94710d..ec557c81 100644 --- a/packages/docs/zh/api/interfaces/RouterHistory.md +++ b/packages/docs/zh/api/interfaces/RouterHistory.md @@ -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}% diff --git a/packages/docs/zh/api/interfaces/RouterOptions.md b/packages/docs/zh/api/interfaces/RouterOptions.md index a713881a..0f0229f5 100644 --- a/packages/docs/zh/api/interfaces/RouterOptions.md +++ b/packages/docs/zh/api/interfaces/RouterOptions.md @@ -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}% diff --git a/packages/docs/zh/api/interfaces/RouterScrollBehavior.md b/packages/docs/zh/api/interfaces/RouterScrollBehavior.md index c0eb1742..4092cee4 100644 --- a/packages/docs/zh/api/interfaces/RouterScrollBehavior.md +++ b/packages/docs/zh/api/interfaces/RouterScrollBehavior.md @@ -6,11 +6,15 @@ editLink: false # 接口:RouterScrollBehavior + + +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`\> diff --git a/packages/docs/zh/guide/advanced/dynamic-routing.md b/packages/docs/zh/guide/advanced/dynamic-routing.md index 5ad3bcac..380b7f22 100644 --- a/packages/docs/zh/guide/advanced/dynamic-routing.md +++ b/packages/docs/zh/guide/advanced/dynamic-routing.md @@ -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) )这样的应用程序可以使用它来扩展应用程序。 ## 添加路由 diff --git a/packages/docs/zh/guide/advanced/lazy-loading.md b/packages/docs/zh/guide/advanced/lazy-loading.md index c4e0dffd..80e2829d 100644 --- a/packages/docs/zh/guide/advanced/lazy-loading.md +++ b/packages/docs/zh/guide/advanced/lazy-loading.md @@ -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') }, + ], }) ``` diff --git a/packages/docs/zh/guide/advanced/meta.md b/packages/docs/zh/guide/advanced/meta.md index a2a53094..84f90972 100644 --- a/packages/docs/zh/guide/advanced/meta.md +++ b/packages/docs/zh/guide/advanced/meta.md @@ -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 字段: + + +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 { // 是可选的 diff --git a/packages/docs/zh/guide/advanced/navigation-failures.md b/packages/docs/zh/guide/advanced/navigation-failures.md index c9cb90da..b1bfe9d3 100644 --- a/packages/docs/zh/guide/advanced/navigation-failures.md +++ b/packages/docs/zh/guide/advanced/navigation-failures.md @@ -62,6 +62,20 @@ if (isNavigationFailure(failure, NavigationFailureType.aborted)) { 如果你忽略第二个参数: `isNavigationFailure(failure)`,那么就只会检查这个 `failure` 是不是一个 _Navigation Failure_。 ::: + + +## 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` 来区分。总共有三种不同的类型: diff --git a/packages/docs/zh/guide/advanced/navigation-guards.md b/packages/docs/zh/guide/advanced/navigation-guards.md index 3f56595d..625e1d7e 100644 --- a/packages/docs/zh/guide/advanced/navigation-guards.md +++ b/packages/docs/zh/guide/advanced/navigation-guards.md @@ -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)中。 + + +## 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 index 00000000..49b7d57f --- /dev/null +++ b/packages/docs/zh/guide/advanced/router-view-slot.md @@ -0,0 +1,75 @@ + + +# RouterView slot + +The RouterView component exposes a slot that can be used to render the route component: + +```vue-html + + + +``` + +The code above is equivalent to using `` 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 + + + + + +``` + +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 + + + + + +``` + +We can also use KeepAlive inside a Transition: + +```vue-html + + + + + + + +``` + +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 + + +

Some slotted content

+
+
+``` + +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 + + + +``` + +If we put the ref on the `` instead then the ref would be populated with the RouterView instance, rather than the route component. diff --git a/packages/docs/zh/guide/advanced/scroll-behavior.md b/packages/docs/zh/guide/advanced/scroll-behavior.md index c34d043d..f0d77b19 100644 --- a/packages/docs/zh/guide/advanced/scroll-behavior.md +++ b/packages/docs/zh/guide/advanced/scroll-behavior.md @@ -43,7 +43,8 @@ const router = createRouter({ // 也可以这么写 // el: document.getElementById('main'), el: '#main', - top: -10, + // 在元素上 10 像素 + top: 10, } }, }) diff --git a/packages/docs/zh/guide/advanced/transitions.md b/packages/docs/zh/guide/advanced/transitions.md index cc10eebc..aaabd9e3 100644 --- a/packages/docs/zh/guide/advanced/transitions.md +++ b/packages/docs/zh/guide/advanced/transitions.md @@ -5,9 +5,9 @@ title="Learn about route transitions" /> -想要在你的路径组件上使用转场,并对导航进行动画处理,你需要使用 [v-slot API](/guide/advanced/composition-api#uselink): +想要在你的路径组件上使用转场,并对导航进行动画处理,你需要使用 [`` 插槽](./router-view-slot): -```vue-html +```html @@ -36,7 +36,7 @@ const routes = [ ] ``` -```vue-html +```html @@ -49,7 +49,7 @@ const routes = [ 也可以根据目标路由和当前路由之间的关系,动态地确定使用的过渡。使用和刚才非常相似的片段: -```vue-html +```html diff --git a/packages/docs/zh/guide/essentials/history-mode.md b/packages/docs/zh/guide/essentials/history-mode.md index edc44085..888cb68c 100644 --- a/packages/docs/zh/guide/essentials/history-mode.md +++ b/packages/docs/zh/guide/essentials/history-mode.md @@ -24,6 +24,24 @@ const router = createRouter({ 它在内部传递的实际 URL 之前使用了一个哈希字符(`#`)。由于这部分 URL 从未被发送到服务器,所以它不需要在服务器层面上进行任何特殊处理。不过,**它在 SEO 中确实有不好的影响**。如果你担心这个问题,可以使用 HTML5 模式。 + + +## 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({ ``` -也可以使用 [`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 diff --git a/packages/docs/zh/guide/essentials/named-routes.md b/packages/docs/zh/guide/essentials/named-routes.md index 4541f370..81bb0b60 100644 --- a/packages/docs/zh/guide/essentials/named-routes.md +++ b/packages/docs/zh/guide/essentials/named-routes.md @@ -24,7 +24,7 @@ const routes = [ 要链接到一个命名的路由,可以向 `router-link` 组件的 `to` 属性传递一个对象: -```vue-html +```html User @@ -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). + + + +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. diff --git a/packages/docs/zh/guide/essentials/named-views.md b/packages/docs/zh/guide/essentials/named-views.md index e87f9eb2..11e8f5f1 100644 --- a/packages/docs/zh/guide/essentials/named-views.md +++ b/packages/docs/zh/guide/essentials/named-views.md @@ -7,7 +7,7 @@ 有时候想同时 (同级) 展示多个视图,而不是嵌套展示,例如创建一个布局,有 `sidebar` (侧导航) 和 `main` (主内容) 两个视图,这个时候命名视图就派上用场了。你可以在界面中拥有多个单独命名的视图,而不是只有一个单独的出口。如果 `router-view` 没有设置名字,那么默认为 `default`。 -```vue-html +```html @@ -59,7 +59,7 @@ const router = createRouter({ `UserSettings` 组件的 `