From: Jinjiang Date: Sat, 1 Apr 2023 03:39:28 +0000 (+0800) Subject: docs(zh): update the API references to the latest (#1738) X-Git-Tag: v4.2.0~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f8622da7242312764345731bcf50eed0e06c0e2;p=thirdparty%2Fvuejs%2Frouter.git docs(zh): update the API references to the latest (#1738) --- diff --git a/packages/docs/zh/api/enums/NavigationFailureType.md b/packages/docs/zh/api/enums/NavigationFailureType.md new file mode 100644 index 00000000..92b9d6ab --- /dev/null +++ b/packages/docs/zh/api/enums/NavigationFailureType.md @@ -0,0 +1,37 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / NavigationFailureType + +# Enumeration: NavigationFailureType + +Enumeration with all possible types for navigation failures. Can be passed to +[isNavigationFailure](../index.md#isnavigationfailure) to check for specific failures. + +## Enumeration Members %{#Enumeration-Members}% + +### aborted %{#Enumeration-Members-aborted}% + +• **aborted** = ``4`` + +An aborted navigation is a navigation that failed because a navigation +guard returned `false` or called `next(false)` + +___ + +### cancelled %{#Enumeration-Members-cancelled}% + +• **cancelled** = ``8`` + +A cancelled navigation is a navigation that failed because a more recent +navigation finished started (not necessarily finished). + +___ + +### duplicated %{#Enumeration-Members-duplicated}% + +• **duplicated** = ``16`` + +A duplicated navigation is a navigation that failed because it was +initiated while already being at the exact same location. diff --git a/packages/docs/zh/api/index.md b/packages/docs/zh/api/index.md index f21a811c..81e755bc 100644 --- a/packages/docs/zh/api/index.md +++ b/packages/docs/zh/api/index.md @@ -1,1118 +1,394 @@ ---- -sidebar: auto ---- +API 文档 -# API 参考 +# API 文档 -## `` Props +## TS 枚举 %{#Enumerations}% -### to +- [NavigationFailureType](enums/NavigationFailureType.md) -- **类型**:[`RouteLocationRaw`](#routelocationraw) -- **详细内容**: +## TS 接口 %{#Interfaces}% - 表示目标路由的链接。当被点击后,内部会立刻把 `to` 的值传到 `router.push()`,所以这个值可以是一个 `string` 或者是[描述目标位置的对象](#routelocationraw)。 +- [HistoryState](interfaces/HistoryState.md) +- [NavigationFailure](interfaces/NavigationFailure.md) +- [NavigationGuard](interfaces/NavigationGuard.md) +- [NavigationGuardNext](interfaces/NavigationGuardNext.md) +- [NavigationGuardWithThis](interfaces/NavigationGuardWithThis.md) +- [NavigationHookAfter](interfaces/NavigationHookAfter.md) +- [RouteLocation](interfaces/RouteLocation.md) +- [RouteLocationMatched](interfaces/RouteLocationMatched.md) +- [RouteLocationNormalized](interfaces/RouteLocationNormalized.md) +- [RouteLocationNormalizedLoaded](interfaces/RouteLocationNormalizedLoaded.md) +- [RouteLocationOptions](interfaces/RouteLocationOptions.md) +- [RouteMeta](interfaces/RouteMeta.md) +- [RouteRecordNormalized](interfaces/RouteRecordNormalized.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) -```html - -Home - -Home +## TS 类型别名 %{#Type-Aliases}% - -Home +### LocationQuery %{#Type-Aliases-LocationQuery}% - -Home +Ƭ **LocationQuery**: `Record`<`string`, `LocationQueryValue` \| `LocationQueryValue`[]\> - -User +出现在 [RouteLocationNormalized](interfaces/RouteLocationNormalized.md) 中的规范化查询对象。 - - - Register - -``` - -### replace - -- **类型**:`boolean` -- **默认值**:`false` -- **详细内容**: - - 设置 `replace` 属性的话,当点击时,会调用 `router.replace()`,而不是 `router.push()`,所以导航后不会留下历史记录。 - -```html - -``` +___ -### active-class +### LocationQueryRaw %{#Type-Aliases-LocationQueryRaw}% -- **类型**:`string` -- **默认值**:`"router-link-active"` (或者全局 [`linkActiveClass`](#linkactiveclass)) -- **详细内容**: +Ƭ **LocationQueryRaw**: `Record`<`string` \| `number`, `LocationQueryValueRaw` \| `LocationQueryValueRaw`[]\> - 链接激活时,应用于渲染的 `` 的 class。 +松散的 [LocationQuery](index.md#locationquery) 对象,可以被传递给诸如 +[push](interfaces/Router.md#push)、[replace](interfaces/Router.md#replace) 或任何创建 +[RouteLocationRaw](index.md#routelocationraw) 的函数。 -### aria-current-value +___ -- **类型**:`'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false'` (`string`) -- **默认值**:`"page"` -- **详细内容**: +### PathParserOptions %{#Type-Aliases-PathParserOptions}% - 当链接激活时,传递给属性 `aria-current` 的值。 +Ƭ **PathParserOptions**: `Pick`<`_PathParserOptions`, ``"end"`` \| ``"sensitive"`` \| ``"strict"``\> -### custom +___ -- **类型**:`boolean` -- **默认值**:`false` -- **详细内容**: +### RouteComponent %{#Type-Aliases-RouteComponent}% - `` 是否应该将其内容包裹在 `` 元素中。在使用 [`v-slot`](#router-link-s-v-slot) 创建自定义 RouterLink 时很有用。默认情况下,`` 会将其内容包裹在 `` 元素中,即使使用 `v-slot` 也是如此。传递 `custom` prop,可以去除这种行为。 +Ƭ **RouteComponent**: `Component` \| `DefineComponent` -- **例如**: +在 [RouteLocationMatched](interfaces/RouteLocationMatched.md) 中允许的组件。 - ```html - - {{ route.fullPath }} - - ``` +___ - 渲染成 `/home`。 +### RouteLocationRaw %{#Type-Aliases-RouteLocationRaw}% - ```html - - {{ route.fullPath }} - - ``` +Ƭ **RouteLocationRaw**: `string` \| `RouteLocationPathRaw` \| `RouteLocationNamedRaw` - 渲染成 `/home`。 +用户级别的路由位置。 -### exact-active-class +___ -- **类型**:`string` -- **默认值**:`"router-link-exact-active"` (或者全局 [`linkExactActiveClass`](#linkexactactiveclass)) -- **详细内容**: +### RouteParams %{#Type-Aliases-RouteParams}% - 链接精准激活时,应用于渲染的 `` 的 class。 +Ƭ **RouteParams**: `Record`<`string`, `RouteParamValue` \| `RouteParamValue`[]\> -## `` 的 `v-slot` +___ -`` 通过一个[作用域插槽](https://v3.vuejs.org/guide/component-slots.html#scoped-slots)暴露底层的定制能力。这是一个更高阶的 API,主要面向库作者,但也可以为开发者提供便利,大多数情况下用在一个类似 _NavLink_ 这样的组件里。 +### RouteParamsRaw %{#Type-Aliases-RouteParamsRaw}% -:::tip 注意 -记得把 `custom` 配置传递给 ``,以防止它将内容包裹在 `` 元素内。 -::: +Ƭ **RouteParamsRaw**: `Record`<`string`, `RouteParamValueRaw` \| `Exclude`<`RouteParamValueRaw`, ``null`` \| `undefined`\>[]\> -```html - - - {{ route.fullPath }} - - -``` +___ -- `href`:解析后的 URL。将会作为一个 `` 元素的 `href` 属性。如果什么都没提供,则它会包含 `base`。 -- `route`:解析后的规范化的地址。 -- `navigate`:触发导航的函数。 **会在必要时自动阻止事件**,和 `router-link` 一样。例如:`ctrl` 或者 `cmd` + 点击仍然会被 `navigate` 忽略。 -- `isActive`:如果需要应用 [active class](#active-class),则为 `true`。允许应用一个任意的 class。 -- `isExactActive`:如果需要应用 [exact active class](#exact-active-class),则为 `true`。允许应用一个任意的 class。 - -### 示例:将激活的 class 应用在外层元素 - -有时我们可能想把激活的 class 应用到一个外部元素而不是 `` 标签本身,这时你可以在一个 `router-link` 中包裹该元素并使用 `v-slot` 属性来创建链接: - -```html - -
  • - {{ route.fullPath }} -
  • - -``` +### RouteRecord %{#Type-Aliases-RouteRecord}% -:::tip 提示 -如果你在 `a` 元素上添加一个 `target="_blank"`,你必须省略 `@click="navigate"` 的处理。 -::: +Ƭ **RouteRecord**: [`RouteRecordNormalized`](interfaces/RouteRecordNormalized.md) -## `` Props +一个[路由记录](index.md#routerecord)的规范化版本。 -### name +___ -- **类型**:`string` -- **默认值**:`"default"` -- **详细内容**: +### RouteRecordName %{#Type-Aliases-RouteRecordName}% - 如果 `` 设置了 `name`,则会渲染对应的路由配置中 `components` 下的相应组件。 +Ƭ **RouteRecordName**: `string` \| `symbol` -- **更多的内容请看**:[命名视图](../guide/essentials/named-views.md) +用户定义的路由记录的可能的名称。 -### route +___ -- **类型**:[`RouteLocationNormalized`](#routelocationnormalized) -- **详细内容**: +### RouteRecordRaw %{#Type-Aliases-RouteRecordRaw}% - 一个路由地址的所有组件都已被解析(如果所有组件都被懒加载),因此可以显示。 +Ƭ **RouteRecordRaw**: `RouteRecordSingleView` \| `RouteRecordSingleViewWithChildren` \| `RouteRecordMultipleViews` \| `RouteRecordMultipleViewsWithChildren` \| `RouteRecordRedirect` -## `` 的 `v-slot` +___ -`` 暴露了一个 `v-slot` API,主要使用 `` 和 `` 组件来包裹你的路由组件。 +### UseLinkOptions %{#Type-Aliases-UseLinkOptions}% -```html - - - - - - - - - - -``` +Ƭ **UseLinkOptions**: `VueUseOptions`<`RouterLinkOptions`\> -- `Component`: VNodes, 传递给 ``的`is` prop。 -- `route`: 解析出的标准化[路由地址](#routelocationnormalized)。 +## 变量 %{#Variables}% -## createRouter +### RouterLink %{#Variables-RouterLink}% -创建一个可以被 Vue 应用程序使用的路由实例。查看 [`RouterOptions`](#routeroptions) 中的所有可以传递的属性列表。 +• `Const` **RouterLink**: `_RouterLinkI` -**函数签名:** +用来渲染一个链接的组件,该链接在被点击时会触发导航。 -```typescript -export declare function createRouter(options: RouterOptions): Router -``` +___ -### 参数 +### RouterView %{#Variables-RouterView}% -| 参数 | 类型 | 描述 | -| ------- | ------------------------------- | ------------------------- | -| options | [RouterOptions](#routeroptions) | Options 用来初始化 router | +• `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`; }\>[] } } -## createWebHistory - -创建一个 HTML5 历史,即单页面应用程序中最常见的历史记录。应用程序必须通过 http 协议被提供服务。 - -**函数签名:** - -```typescript -export declare function createWebHistory(base?: string): RouterHistory -``` - -### 参数 - -| 参数 | 类型 | 描述 | -| ---- | -------- | ------------------------------------------------------------------------------------------------ | -| base | `string` | 提供的可选 base。当应用程序被托管在诸如 `https://example.com/folder/` 之类的文件夹中时非常有用。 | - -### 示例 - -```js -createWebHistory() // 没有 base,应用托管在域名 `https://example.com` 的根目录下。 -createWebHistory('/folder/') // 给出的网址为 `https://example.com/folder/` -``` +#### 类型声明 %{#Variables-RouterView-Type-declaration}% -## createWebHashHistory +• **new RouterView**() -创建一个 hash 历史记录。对于没有主机的 web 应用程序 (例如 `file://`),或当配置服务器不能处理任意 URL 时这非常有用。**注意:如果 SEO 对你很重要,你应该使用 [`createWebHistory`](#createwebhistory)**。 +用于显示用户当前所处路由的组件。 -**函数签名:** +___ -```typescript -export declare function createWebHashHistory(base?: string): RouterHistory -``` +### START\_LOCATION %{#Variables-START_LOCATION}% -### 参数 +• `Const` **START\_LOCATION**: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) -| 参数 | 类型 | 描述 | -| ---- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| base | `string` | 提供可选的 base。默认是 `location.pathname + location.search`。如果 `head` 中有一个 ``,它的值将被忽略,而采用这个参数。**但请注意它会影响所有的 history.pushState() 调用**,这意味着如果你使用一个 `` 标签,它的 `href` 值**必须与这个参数相匹配** (请忽略 `#` 后面的所有内容) | +路由器的初始路由位置。可以在导航守卫中使用来区分初始导航。 -### 示例 +**示例** ```js -// at https://example.com/folder -createWebHashHistory() // 给出的网址为 `https://example.com/folder#` -createWebHashHistory('/folder/') // 给出的网址为 `https://example.com/folder/#` -// 如果在 base 中提供了 `#`,则它不会被 `createWebHashHistory` 添加 -createWebHashHistory('/folder/#/app/') // 给出的网址为 `https://example.com/folder/#/app/` -// 你应该避免这样做,因为它会更改原始 url 并打断正在复制的 url -createWebHashHistory('/other-folder/') // 给出的网址为 `https://example.com/other-folder/#` - -// at file:///usr/etc/folder/index.html -// 对于没有 `host` 的位置,base被忽略 -createWebHashHistory('/iAmIgnored') // 给出的网址为 `file:///usr/etc/folder/index.html#` -``` - -## createMemoryHistory - -创建一个基于内存的历史记录。这个历史记录的主要目的是处理 SSR。它在一个特殊的位置开始,这个位置无处不在。如果用户不在浏览器上下文中,它们可以通过调用 `router.push()` 或 `router.replace()` 将该位置替换为启动位置。 - -**函数签名:** - -```typescript -export declare function createMemoryHistory(base?: string): RouterHistory -``` - -### 参数 - -| 参数 | 类型 | 描述 | -| ---- | -------- | ------------------------------ | -| base | `string` | Base 适用于所有 URL,默认为'/' | - -### Returns - -一个可以传递给路由构造函数的历史对象。 - -## NavigationFailureType - -包含所有可能导航失败类型的枚举,可以传递给 [isNavigationFailure](#isnavigationfailure) 来检查某些特定类型的失败。**不要使用任何数值**,总是使用诸如 `NavigationFailureType.aborted` 这样的变量。 - -**函数签名:** - -```typescript -export declare enum NavigationFailureType -``` - -### 成员 - -| 成员 | 值 | 描述 | -| ---------- | --- | ------------------------------------------------------------------------ | -| aborted | 4 | 终止导航是指由于导航守卫返回 `false` 或调用 `next(false)` 而失败的导航。 | -| cancelled | 8 | 取消导航是指由于最近的导航完成启动(不一定是完成)而失败的导航。 | -| duplicated | 16 | 重复导航是指在启动时已经在同一位置失败的导航。 | - -## START_LOCATION - -- **类型**:[`RouteLocationNormalized`](#routelocationnormalized) -- **详细内容**: - - 路由所在的初始路由地址。可用于导航守卫中,以区分初始导航。 - - ```js - import { START_LOCATION } from 'vue-router' - - router.beforeEach((to, from) => { - if (from === START_LOCATION) { - // 初始导航 - } - }) - ``` - -## Composition API - -### onBeforeRouteLeave - -添加一个导航守卫,在当前位置的组件将要离开时触发。类似于 `beforeRouteLeave`,但它可以在任何组件中使用。当组件被卸载时,导航守卫将被移除。 - -**函数签名:** - -```typescript -export declare function onBeforeRouteLeave(leaveGuard: NavigationGuard): void -``` - -#### 参数 - -| 参数 | 类型 | 描述 | -| ---------- | ------------------------------------- | ---------------- | -| leaveGuard | [`NavigationGuard`](#navigationguard) | 要添加的导航守卫 | - -### onBeforeRouteUpdate - -添加一个导航守卫,在当前位置即将更新时触发。类似于 `beforeRouteUpdate`,但它可以在任何组件中使用。当组件被卸载时,导航守卫将被移除。 - -**函数签名:** - -```typescript -export declare function onBeforeRouteUpdate(updateGuard: NavigationGuard): void -``` - -#### 参数 - -| 参数 | 类型 | 描述 | -| ----------- | ------------------------------------- | ---------------- | -| updateGuard | [`NavigationGuard`](#navigationguard) | 要添加的导航守卫 | - -### useLink - -返回 [`v-slot` API](#router-link-s-v-slot) 暴露的所有内容。 - -**函数签名:** - -```typescript -export declare function useLink(props: RouterLinkOptions): { - route: ComputedRef, - href: ComputedRef, - isActive: ComputedRef, - isExactActive: ComputedRef, - navigate: (event?: MouseEvent) => Promise(NavigationFailure | void), -} -``` - -#### 参数 - -| 参数 | 类型 | 描述 | -| ----- | ------------------- | ---------------------------------------------------------------- | -| props | `RouterLinkOptions` | props 对象可以传递给``。接收 `Ref` 和 `ComputedRef` | - -### useRoute - -返回当前路由地址。相当于在模板中使用 `$route`。必须在 `setup()` 中调用。 - -**函数签名:** - -```typescript -export declare function useRoute(): RouteLocationNormalized -``` - -### useRouter - -返回 [router](#router-properties) 实例。相当于在模板中使用 `$router`。必须在 `setup()` 中调用。 - -**函数签名:** - -```typescript -export declare function useRouter(): Router -``` - -## TypeScript +import { START_LOCATION } from 'vue-router' -下面是 Vue Router 使用的一些接口和类型。文档引用它们是为了让你了解对象中现有的属性。 - -## Router 属性 - -### currentRoute - -- **类型**:[`Ref`](#routelocationnormalized) -- **详细内容**: - - 当前路由地址。只读的。 - -### options - -- **类型**:[`RouterOptions`](#routeroptions) -- **详细内容**: - - 创建 Router 时传递的原始配置对象。只读的。 - -## Router 方法 - -### addRoute - -添加一条新的[路由记录](#routerecordraw)作为现有路由的子路由。如果路由有一个 `name`,并且已经有一个与之名字相同的路由,它会先删除之前的路由。 - -**函数签名:** - -```typescript -addRoute(parentName: string | symbol, route: RouteRecordRaw): () => void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ---------- | ----------------------------------- | -------------------------------------- | -| parentName | `string \| symbol` | 父路由记录,`route` 应该被添加到的位置 | -| route | [`RouteRecordRaw`](#routerecordraw) | 要添加的路由记录 | - -### addRoute - -添加一条新的[路由记录](#routerecordraw)到路由。如果路由有一个 `name`,并且已经有一个与之名字相同的路由,它会先删除之前的路由。 - -**函数签名:** - -```typescript -addRoute(route: RouteRecordRaw): () => void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ----- | ----------------------------------- | ---------------- | -| route | [`RouteRecordRaw`](#routerecordraw) | 要添加的路由记录 | - -:::tip 提示 -请注意,添加路由并不会触发新的导航。也就是说,除非触发新的导航,否则不会显示所添加的路由。 -::: - -### afterEach - -添加一个导航钩子,在每次导航后执行。返回一个删除注册钩子的函数。 - -**函数签名:** - -```typescript -afterEach(guard: NavigationHookAfter): () => void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ----- | --------------------- | ---------------- | -| guard | `NavigationHookAfter` | 要添加的导航钩子 | - -#### 示例 - -```js -router.afterEach((to, from, failure) => { - if (isNavigationFailure(failure)) { - console.log('failed navigation', failure) +router.beforeEach((to, from) => { + if (from === START_LOCATION) { + // 初始导航 } }) ``` -### back - -如果可能的话,通过调用 `history.back()` 回溯历史。相当于 `router.go(-1)`。 - -**函数签名:** - -```typescript -back(): void -``` - -### beforeEach - -添加一个导航守卫,在任何导航前执行。返回一个删除已注册守卫的函数。 - -**函数签名:** - -```typescript -beforeEach(guard: NavigationGuard): () => void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ----- | ------------------------------------- | ---------------- | -| guard | [`NavigationGuard`](#navigationguard) | 要添加的导航守卫 | - -### beforeResolve - -添加一个导航守卫,在导航即将解析之前执行。在这个状态下,所有的组件都已经被获取,并且其他导航守卫也已经成功。返回一个删除已注册守卫的函数。 - -**函数签名:** - -```typescript -beforeResolve(guard: NavigationGuard): () => void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ----- | ------------------------------------- | ---------------- | -| guard | [`NavigationGuard`](#navigationguard) | 要添加的导航守卫 | - -#### 示例 - -```js -router.beforeResolve(to => { - if (to.meta.requiresAuth && !isAuthenticated) return false -}) -``` - -### forward - -如果可能的话,通过调用 `history.forward()` 在历史中前进。相当于 `router.go(1)`。 - -**函数签名:** - -```typescript -forward(): void -``` - -### getRoutes - -获取所有 [路由记录](#routerecordnormalized)的完整列表。 - -**函数签名:** - -```typescript -getRoutes(): RouteRecord[] -``` - -### go - -允许你在历史中前进或后退。 - -**函数签名:** - -```typescript -go(delta: number): void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ----- | -------- | ------------------------------------ | -| delta | `number` | 相对于当前页面,你要移动到的历史位置 | - -### hasRoute - -确认是否存在指定名称的路由。 - -**函数签名:** - -```typescript -hasRoute(name: string | symbol): boolean -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ---- | ------------------ | ---------------- | -| name | `string \| symbol` | 要确认的路由名称 | - -### isReady - -当路由器完成初始化导航时,返回一个 Promise,这意味着它已经解析了所有与初始路由相关的异步输入钩子和异步组件。如果初始导航已经发生了,那么 promise 就会立即解析。这在服务器端渲染中很有用,可以确保服务器和客户端的输出一致。需要注意的是,在服务器端,你需要手动推送初始位置,而在客户端,路由器会自动从 URL 中获取初始位置。 - -**函数签名:** - -```typescript -isReady(): Promise -``` - -### onError - -添加一个错误处理程序,在导航期间每次发生未捕获的错误时都会调用该处理程序。这包括同步和异步抛出的错误、在任何导航守卫中返回或传递给 `next` 的错误,以及在试图解析渲染路由所需的异步组件时发生的错误。 - -**函数签名:** - -```typescript -onError(handler: (error: any, to: RouteLocationNormalized, from: RouteLocationNormalized) => any): () => void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ------- | --------------------------------------------------------------------------------- | ------------------------- | -| handler | `(error: any, to: RouteLocationNormalized, from: RouteLocationNormalized) => any` | 注册的错误处理程序 | - -### push - -通过在历史堆栈中推送一个 entry,以编程方式导航到一个新的 URL。 - -**函数签名:** - -```typescript -push(to: RouteLocationRaw): Promise -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ---- | --------------------------------------- | ------------------ | -| to | [`RouteLocationRaw`](#routelocationraw) | 要导航到的路由地址 | - -### removeRoute - -通过名称删除现有路由。 - -**函数签名:** - -```typescript -removeRoute(name: string | symbol): void -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ---- | ------------------ | ---------------- | -| name | `string \| symbol` | 要删除的路由名称 | - -### replace - -通过替换历史堆栈中的当前 entry,以编程方式导航到一个新的 URL。 - -**函数签名:** - -```typescript -replace(to: RouteLocationRaw): Promise -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ---- | --------------------------------------- | ------------------ | -| to | [`RouteLocationRaw`](#routelocationraw) | 要导航到的路由地址 | - -### resolve - -返回[路由地址](#routelocationraw)的[标准化版本](#routelocation)。还包括一个包含任何现有 `base` 的 `href` 属性。 - -**函数签名:** - -```typescript -resolve(to: RouteLocationRaw): RouteLocation & { - href: string -} -``` - -_参数_ - -| 参数 | 类型 | 描述 | -| ---- | --------------------------------------- | -------------------- | -| to | [`RouteLocationRaw`](#routelocationraw) | 要解析的原始路由地址 | - -## RouterOptions - -### history - -用于路由实现历史记录。大多数 web 应用程序都应该使用 `createWebHistory`,但它要求正确配置服务器。你还可以使用 `createWebHashHistory` 的基于 _hash_ 的历史记录,它不需要在服务器上进行任何配置,但是搜索引擎根本不会处理它,在 SEO 上表现很差。 - -**函数签名:** - -```typescript -history: RouterHistory -``` - -#### 示例 - -```js -createRouter({ - history: createWebHistory(), - // 其他配置... -}) -``` - -### linkActiveClass +## 函数 %{#Functions}% -用于激活的 [RouterLink](#router-link-props) 的默认类。如果什么都没提供,则会使用 `router-link-active`。 +### createMemoryHistory %{#Functions-createMemoryHistory}% -**函数签名:** +▸ **createMemoryHistory**(`base?`): [`RouterHistory`](interfaces/RouterHistory.md) -```typescript -linkActiveClass?: string -``` +创建一个基于内存的历史。该历史的主要目的是为了处理服务端渲染。它从一个不存在的特殊位置开始。用户可以通过调用 `router.push` 或 `router.replace` 将该位置替换成起始位置。 -### linkExactActiveClass +#### 参数 %{#Functions-createMemoryHistory-Parameters}% -用于精准激活的 [RouterLink](#router-link-props) 的默认类。如果什么都没提供,则会使用 `router-link-exact-active`。 +| 名称 | 类型 | 默认值 | 描述 | +| :------ | :------ | :------ | :------ | +| `base` | `string` | `''` | 所有 URL 的基础位置,默认为 '/' | -**函数签名:** - -```typescript -linkExactActiveClass?: string -``` +#### 返回值 %{#Functions-createMemoryHistory-Returns}% -### parseQuery +[`RouterHistory`](interfaces/RouterHistory.md) -用于解析查询的自定义实现。必须解码查询键和值。参见对应的 [stringifyQuery](#stringifyquery)。 +一个历史对象,可以传递给路由器构造函数。 -**函数签名:** +___ -```typescript -parseQuery?: (searchQuery: string) => Record -``` +### createRouter %{#Functions-createRouter}% -#### 示例 +▸ **createRouter**(`options`): [`Router`](interfaces/Router.md) -比方说,你想使用 [qs](https://github.com/ljharb/qs) 包来解析查询,你可以同时提供 `parseQuery` 和 `stringifyQuery`: +创建一个可以被 Vue 应用使用的 Router 实例。 -```js -import qs from 'qs' +#### 参数 %{#Functions-createRouter-Parameters}% -createRouter({ - // 其他配置... - parseQuery: qs.parse, - stringifyQuery: qs.stringify, -}) -``` +| 名称 | 类型 | 描述 | +| :------ | :------ | :------ | +| `options` | [`RouterOptions`](interfaces/RouterOptions.md) | [RouterOptions](interfaces/RouterOptions.md) | -### routes +#### 返回值 %{#Functions-createRouter-Returns}% -应该添加到路由的初始路由列表。 +[`Router`](interfaces/Router.md) -**函数签名:** +___ -```typescript -routes: RouteRecordRaw[] -``` +### createWebHashHistory %{#Functions-createWebHashHistory}% -### scrollBehavior +▸ **createWebHashHistory**(`base?`): [`RouterHistory`](interfaces/RouterHistory.md) -在页面之间导航时控制滚动的函数。可以返回一个 Promise 来延迟滚动。有关更多详细信息,请参见[滚动行为](../guide/advanced/scroll-behavior.md)。 +创建一个 hash 模式的历史。在没有主机的 web 应用 (如 `file://`) 或无法通过配置服务器来处理任意 URL 的时候非常有用。 -**函数签名:** - -```typescript -scrollBehavior?: RouterScrollBehavior -``` - -#### 示例 +**示例** ```js -function scrollBehavior(to, from, savedPosition) { - // `to` 和 `from` 都是路由地址 - // `savedPosition` 可以为空,如果没有的话。 -} -``` - -### stringifyQuery +// 基于 https://example.com/folder +createWebHashHistory() // 给出一个 `https://example.com/folder#` 的 URL +createWebHashHistory('/folder/') // 给出一个 `https://example.com/folder/#` 的 URL +// 如果其基础位置提供了 `#`,则不会被 `createWebHashHistory` 添加 +createWebHashHistory('/folder/#/app/') // 给出一个 `https://example.com/folder/#/app/` 的 URL +// 你应该避免这样做,因为它改变了原始的 URL 且破坏了复制 URL 的工作 +createWebHashHistory('/other-folder/') // 给出一个 `https://example.com/other-folder/#` 的 URL -对查询对象进行字符串化的自定义实现。不应该在前面加上 `?`。应该正确编码查询键和值。 [parseQuery](#parsequery) 对应于处理查询解析。 - -**函数签名:** - -```typescript -stringifyQuery?: ( - query: Record< - string | number, - string | number | null | undefined | (string | number | null | undefined)[] - > -) => string +// 基于 file:///usr/etc/folder/index.html +// 对于没有 `host` 的位置,该 base 会被忽略 +createWebHashHistory('/iAmIgnored') // 给出一个 `file:///usr/etc/folder/index.html#` 的 URL ``` -## RouteRecordRaw - -当用户通过 [`routes` option](#routeroptions) 或者 [`router.addRoute()`](#addroute) 来添加路由时,可以得到路由记录。 有三种不同的路由记录: - -- 单一视图记录:有一个 `component` 配置 -- 多视图记录 ([命名视图](../guide/essentials/named-views.md)) :有一个 `components` 配置 -- 重定向记录:没有 `component` 或 `components` 配置,因为重定向记录永远不会到达。 +#### 参数 %{#Functions-createWebHashHistory-Parameters}% -### path +| 名称 | 类型 | 描述 | +| :------ | :------ | :------ | +| `base?` | `string` | 可选提供的基础位置。默认为 `location.pathname + location.search`。如果在 `head` 中有一个 `` 标签,它的值会因此被忽略,**但注意它会影响所有 history.pushState() 的调用**,这意味着如果你使用一个 `` 标签,它的 `href` 值**必须与这个参数匹配** (忽略 `#` 后的任何东西)。 | -- **类型**:`string` -- **详细内容**: +#### 返回值 %{#Functions-createWebHashHistory-Returns}% - 记录的路径。应该以 `/` 开头,除非该记录是另一条记录的子记录。可以定义参数:`/users/:id` 匹配 `/users/1` 以及 `/users/posva`。 +[`RouterHistory`](interfaces/RouterHistory.md) -- **更多的内容请看**:[动态路由匹配](../guide/essentials/dynamic-matching.md) +___ -### redirect +### createWebHistory %{#Functions-createWebHistory}% -- **类型**:`RouteLocationRaw | (to: RouteLocationNormalized) => RouteLocationRaw` (可选) -- **详细内容**: +▸ **createWebHistory**(`base?`): [`RouterHistory`](interfaces/RouterHistory.md) - 如果路由是直接匹配的,那么重定向到哪里呢。重定向发生在所有导航守卫之前,并以新的目标位置触发一个新的导航。也可以是一个接收目标路由地址并返回我们应该重定向到的位置的函数。 +创建一个 HTML5 历史。对于单页应用来说这是最常见的历史。 -### children +#### 参数 %{#Functions-createWebHistory-Parameters}% -- **类型**:[`RouteRecordRaw`](#routerecordraw) 数组 (可选) -- **详细内容**: +| 名称 | 类型 | +| :------ | :------ | +| `base?` | `string` | - 当前记录的嵌套路由。 +#### 返回值 %{#Functions-createWebHistory-Returns}% -- **更多的内容请看**:[Nested Routes](../guide/essentials/nested-routes.md) +[`RouterHistory`](interfaces/RouterHistory.md) -### alias +___ -- **类型**:`string | string[]` (可选) -- **详细内容**: +### isNavigationFailure %{#Functions-isNavigationFailure}% - 路由的别名。允许定义类似记录副本的额外路由。这使得路由可以简写为像这种 `/users/:id` 和 `/u/:id`。 **所有的 `alias` 和 `path` 值必须共享相同的参数**。 +▸ **isNavigationFailure**(`error`, `type?`): error is NavigationRedirectError -### name +检查一个对象是否是 [NavigationFailure](interfaces/NavigationFailure.md)。 -- **类型**:`string | symbol` (可选) -- **详细内容**: - - 路由记录独一无二的名称。 - -### beforeEnter - -- **类型**:[`NavigationGuard | NavigationGuard[]`](#navigationguard) (可选) -- **详细内容**: - - 在进入特定于此记录的守卫之前。注意如果记录有`重定向`属性,则 `beforeEnter` 无效。 - -### props - -- **类型**:`boolean | Record | (to: RouteLocationNormalized) => Record` (可选) -- **详细内容**: - - 允许将参数作为 props 传递给由 `router-view` 渲染的组件。当传递给一个**多视图记录**时,它应该是一个与`组件`具有相同键的对象,或者是一个应用于每个组件的`布尔值`。 - -- **更多的内容请看**:[给路由组件传 props](../guide/essentials/passing-props.md) - -### sensitive - -- **类型**: `boolean` (可选) -- **详细内容**: - - 使路由匹配区分大小写,默认为`false`。注意这也可以在路由级别上设置。 - -### strict - -- **类型**: `boolean` (可选) -- **详细内容**: - - 严格检查路径末尾是否有尾部斜线(`/`)。默认为 `false`,意味着默认情况下,路由 `/users` 同时匹配 `/users` 和 `/users/`。注意这也可以在路由级别上设置。 - -### meta - -- **类型**:[`RouteMeta`](#routemeta) (可选) -- **详细内容**: - - 在记录上附加自定义数据。 - -- **更多的内容请看**:[Meta 字段](../guide/advanced/meta.md) - -:::tip 注意 -如果你想使用函数式组件, 请确保在组件上添加一个 `displayName`。 - -例如: +**示例** ```js -const HomeView = () => h('div', 'HomePage') -// 使用TypeScript时, 组件需要为 FunctionalComponent 类型 -HomeView.displayName = 'HomeView' -const routes = [{ path: '/', component: HomeView }] -``` - -::: - -## RouteRecordNormalized - -[路由记录](#routerecordraw)的标准化版本 - -### aliasOf - -- **类型**:`RouteRecordNormalized | undefined` -- **详细内容**: - - 定义此记录是否是另一个记录的别名。如果该记录是原始记录,则此属性为 `undefined`。 - -### beforeEnter - -- **类型**:[`NavigationGuard`](#navigationguard) -- **详细内容**: - - 当从其他地方进入此记录时,导航守卫会被应用。 - -- **更多的内容请看**:[导航守卫](../guide/advanced/navigation-guards.md) - -### children - -- **类型**:标准化[路由记录](#routerecordnormalized)数组 -- **详细内容**: - - 路由被添加时的子路由记录。如果没有则为空数组。注意这个数组在 `addRoute()` 和 `removeRoute()` 被调用时不会更新。 - -### components - -- **类型**:`Record` -- **详细内容**: - - 命名视图的字典,如果没有,包含一个键为 `default` 的对象。 - -### meta +import { isNavigationFailure, NavigationFailureType } from 'vue-router' -- **类型**:`RouteMeta` -- **详细内容**: - - 附在记录上的任意数据。 - -- **更多的内容请看**:[Meta 字段](../guide/advanced/meta.md) - -### name - -- **类型**:`string | symbol | undefined` -- **详细内容**: - - 路由记录的名称。如果什么都没提供,则为 `undefined`。 - -### path - -- **类型**:`string` -- **详细内容**: - - 路由记录的标准化路径。包括所有父级的 `path`。 - -### props - -- **类型**:`Record>` -- **详细内容**: - - 每个命名视图的 [`props` 配置](#props)字典。如果没有,它将只包含一个名为 `default` 的属性。 - -### redirect - -- **类型**:[`RouteLocationRaw`](#routelocationraw) -- **详细内容**: - - 如果路由是直接匹配的,那么重定向到哪里呢。重定向发生在所有导航守卫之前,并触发一个带有新目标位置的新导航。 - -## RouteLocationRaw - -用户级的路由地址,可以传递给 `router.push()`,`redirect`,并在[导航守卫](../guide/advanced/navigation-guards.md)中返回。 - -原始位置可以是一个 `字符串`,比如 `/users/posva#bio`,也可以是一个对象: - -```js -// 这三种形式是等价的 -router.push('/users/posva#bio') -router.push({ path: '/users/posva', hash: '#bio' }) -router.push({ name: 'users', params: { username: 'posva' }, hash: '#bio' }) -// 只改变 hash -router.push({ hash: '#bio' }) -// 只改变 query -router.push({ query: { page: '2' } }) -// 只改变 param -router.push({ params: { username: 'jolyne' } }) -``` - -注意 `path` 必须以编码方式提供(例如,`phantom blood` 变为 `phantom%20blood`)。而 `params`、`query` 和 `hash` 一定不要这样,因为它们会被路由编码。 - -原始路由地址还支持一个额外的配置 `replace` 来调用导航守卫中的 `router.replace()`,而不是 `router.push()`。请注意,即使在调用 `router.push()`时,它也会在内部调用 `router.replace()` : - -```js -router.push({ hash: '#bio', replace: true }) -// 相当于 -router.replace({ hash: '#bio' }) +router.afterEach((to, from, failure) => { + // 任何类型的导航失败 + if (isNavigationFailure(failure)) { + // ... + } + // 重复的导航 + if (isNavigationFailure(failure, NavigationFailureType.duplicated)) { + // ... + } + // 中止或取消的导航 + if (isNavigationFailure(failure, NavigationFailureType.aborted | NavigationFailureType.canceled)) { + // ... + } +}) ``` -## RouteLocation - -可以包含[重定向记录](#routerecordraw)的解析的 [RouteLocationRaw](#routelocationraw)。除此之外,它还具有与 [RouteLocationNormalized](#routelocationnormalized) 相同的属性。 - -## RouteLocationNormalized - -标准化的路由地址。没有任何[重定向记录](#routerecordraw)。在导航守卫中,`to` 和 `from` 总是属于这种类型。 - -### fullPath - -- **类型**:`string` -- **详细内容**: - - URL 编码与路由地址有关。包括 `path`、 `query` 和 `hash`。 - -### hash +#### 参数 %{#Functions-isNavigationFailure-Parameters}% -- **类型**:`string` -- **详细内容**: +| 名称 | 类型 | 描述 | +| :------ | :------ | :------ | +| `error` | `any` | 可能的 [NavigationFailure](interfaces/NavigationFailure.md) | +| `type?` | `NAVIGATION_GUARD_REDIRECT` | 可选的待检查类型 | - 已解码 URL 的 `hash` 部分。总是以 `#`开头。如果 URL 中没有 `hash`,则为空字符串。 +#### 返回值 %{#Functions-isNavigationFailure-Returns}% -### query +error is NavigationRedirectError -- **类型**:`Record` -- **详细内容**: +▸ **isNavigationFailure**(`error`, `type?`): error is NavigationFailure - 从 URL 的 `search` 部分提取的已解码查询参数的字典。 +#### 参数 %{#Functions-isNavigationFailure-Parameters_1}% -### matched +| 名称 | 类型 | +| :------ | :------ | +| `error` | `any` | +| `type?` | `ErrorTypes` \| [`NavigationFailureType`](enums/NavigationFailureType.md) | -- **类型**:[`RouteRecordNormalized[]`](#routerecordnormalized) -- **详细内容**: +#### 返回值 %{#Functions-isNavigationFailure-Returns_1}% - 与给定路由地址匹配的[标准化的路由记录](#routerecord)数组。 +error is NavigationFailure -### meta +___ -- **类型**:`RouteMeta` -- **详细内容**: +### loadRouteLocation %{#Functions-loadRouteLocation}% - 附加到从父级到子级合并(非递归)的所有匹配记录的任意数据。 +▸ **loadRouteLocation**(`route`): `Promise`<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\> -- **更多的内容请看**:[Meta 字段](../guide/advanced/meta.md) +确保路由被加载,所以它可以作为一个 prop 传递给 ``。 -### name +#### 参数 %{#Functions-loadRouteLocation-Parameters}% -- **类型**:`string | symbol | undefined | null` -- **详细内容**: +| 名称 | 类型 | 描述 | +| :------ | :------ | :------ | +| `route` | [`RouteLocationNormalized`](interfaces/RouteLocationNormalized.md) | 解析要加载的路由 | - 路由记录的名称。如果什么都没提供,则为 `undefined`。 +#### 返回值 %{#Functions-loadRouteLocation-Returns}% -### params +`Promise`<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\> -- **类型**:`Record` -- **详细内容**: +___ - 从 `path` 中提取的已解码参数字典。 +### onBeforeRouteLeave %{#Functions-onBeforeRouteLeave}% -### path +▸ **onBeforeRouteLeave**(`leaveGuard`): `void` -- **类型**:`string` -- **详细内容**: +添加一个导航守卫,不论当前位置的组件何时离开都会触发。类似于 beforeRouteLeave,但可以在任意组件中使用。当组件被卸载时,该守卫会被移除。 - 编码 URL 的 `pathname` 部分,与路由地址有关。 +#### 参数 %{#Functions-onBeforeRouteLeave-Parameters}% -### redirectedFrom +| 名称 | 类型 | 描述 | +| :------ | :------ | :------ | +| `leaveGuard` | [`NavigationGuard`](interfaces/NavigationGuard.md) | [NavigationGuard](interfaces/NavigationGuard.md) | -- **类型**:[`RouteLocation`](#routelocation) -- **详细内容**: +#### 返回值 %{#Functions-onBeforeRouteLeave-Returns}% - 在找到 `redirect` 配置或带有路由地址的名为 `next()` 的导航守卫时,我们最初尝试访问的路由地址,最后到达当前位置。如果没有重定向,则为 `undefined`。 +`void` -## NavigationFailure +___ -### from +### onBeforeRouteUpdate %{#Functions-onBeforeRouteUpdate}% -- **类型**:[`RouteLocationNormalized`](#routelocationnormalized) -- **详细内容**: +▸ **onBeforeRouteUpdate**(`updateGuard`): `void` - 导航来的路由地址 +添加一个导航守卫,不论当前位置何时被更新都会触发。类似于 beforeRouteUpdate,但可以在任何组件中使用。当组件被卸载时,该守卫会被移除。 -### to +#### 参数 %{#Functions-onBeforeRouteUpdate-Parameters}% -- **类型**:[`RouteLocationNormalized`](#routelocationnormalized) -- **详细内容**: +| 名称 | 类型 | 描述 | +| :------ | :------ | :------ | +| `updateGuard` | [`NavigationGuard`](interfaces/NavigationGuard.md) | [NavigationGuard](interfaces/NavigationGuard.md) | - 导航去的路由地址 +#### 返回值 %{#Functions-onBeforeRouteUpdate-Returns}% -### type +`void` -- **类型**:[`NavigationFailureType`](#navigationfailuretype) -- **详细内容**: +___ - 导航失败的类型 +### useLink %{#Functions-useLink}% -- **更多的内容请看**:[Navigation Failures](../guide/advanced/navigation-failures.md) +▸ **useLink**(`props`): `Object` -## NavigationGuard +#### 参数 %{#Functions-useLink-Parameters}% -- **Arguments**: +| 名称 | 类型 | +| :------ | :------ | +| `props` | `VueUseOptions`<`RouterLinkOptions`\> | - - [`RouteLocationNormalized`](#routelocationnormalized) to - 我们要导航到的路由地址 - - [`RouteLocationNormalized`](#routelocationnormalized) from - 我们从哪里来的路由地址 - - `Function` next (可选) - 回调以验证导航 +#### 返回值 %{#Functions-useLink-Returns}% -- **详细内容**: +`Object` - 可以通过函数来控制路由导航。如果你返回一个值(或一个 Promise ),则可以省略 `next` 回调,并且我们鼓励这样做。可能的返回值 (和 `next`的参数) 有: +| 名称 | 类型 | +| :------ | :------ | +| `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` }\> | - - `undefined | void | true`: 验证导航 - - `false`: 取消导航 - - [`RouteLocationRaw`](#routelocationraw): 重定向到一个不同的位置 - - `(vm: ComponentPublicInstance) => any` **仅适用于 `beforeRouteEnter`**:导航完成后执行的回调。接收路由组件实例作为参数。 +___ -- **更多的内容请看**:[导航守卫](../guide/advanced/navigation-guards.md) +### useRoute %{#Functions-useRoute}% -## Component Injections +▸ **useRoute**(): [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) -### Component Injected 属性 +返回当前的路由地址。相当于在模板中使用 `$router`。 -这些属性通过调用 `app.use(router)` 注入到每个子组件中。 +#### 返回值 %{#Functions-useRoute-Returns}% -- **this.\$router** +[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) - router 实例 +___ -- **this.\$route** +### useRouter %{#Functions-useRouter}% - 当前激活的[路由地址](#routelocationnormalized)。这个属性是只读的,并且它的属性是不可改变的,但是它可以被观察。 +▸ **useRouter**(): [`Router`](interfaces/Router.md) -### Component Enabled Options +返回路由器实例。相当于在模板中使用 `$router`。 -- **beforeRouteEnter** -- **beforeRouteUpdate** -- **beforeRouteLeave** +#### 返回值 %{#Functions-useRouter-Returns}% -请看[组件内的守卫](../guide/advanced/navigation-guards.md#组件内的守卫)。 +[`Router`](interfaces/Router.md) diff --git a/packages/docs/zh/api/interfaces/HistoryState.md b/packages/docs/zh/api/interfaces/HistoryState.md new file mode 100644 index 00000000..63828f60 --- /dev/null +++ b/packages/docs/zh/api/interfaces/HistoryState.md @@ -0,0 +1,13 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / HistoryState + +# Interface: HistoryState + +Allowed HTML history.state + +## Indexable %{#Indexable}% + +▪ [x: `number`]: `HistoryStateValue` diff --git a/packages/docs/zh/api/interfaces/NavigationFailure.md b/packages/docs/zh/api/interfaces/NavigationFailure.md new file mode 100644 index 00000000..d49b8c4f --- /dev/null +++ b/packages/docs/zh/api/interfaces/NavigationFailure.md @@ -0,0 +1,79 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / NavigationFailure + +# Interface: NavigationFailure + +Extended Error that contains extra information regarding a failed navigation. + +## Hierarchy %{#Hierarchy}% + +- `Error` + + ↳ **`NavigationFailure`** + +## Properties %{#Properties}% + +### cause %{#Properties-cause}% + +• `Optional` **cause**: `unknown` + +#### Inherited from %{#Properties-cause-Inherited-from}% + +Error.cause + +___ + +### from %{#Properties-from}% + +• **from**: [`RouteLocationNormalized`](RouteLocationNormalized.md) + +Route location we were navigating from + +___ + +### message %{#Properties-message}% + +• **message**: `string` + +#### Inherited from %{#Properties-message-Inherited-from}% + +Error.message + +___ + +### name %{#Properties-name}% + +• **name**: `string` + +#### Inherited from %{#Properties-name-Inherited-from}% + +Error.name + +___ + +### stack %{#Properties-stack}% + +• `Optional` **stack**: `string` + +#### Inherited from %{#Properties-stack-Inherited-from}% + +Error.stack + +___ + +### to %{#Properties-to}% + +• **to**: [`RouteLocationNormalized`](RouteLocationNormalized.md) + +Route location we were navigating to + +___ + +### type %{#Properties-type}% + +• **type**: `NAVIGATION_ABORTED` \| `NAVIGATION_CANCELLED` \| `NAVIGATION_DUPLICATED` + +Type of the navigation. One of [NavigationFailureType](../enums/NavigationFailureType.md) diff --git a/packages/docs/zh/api/interfaces/NavigationGuard.md b/packages/docs/zh/api/interfaces/NavigationGuard.md new file mode 100644 index 00000000..59f65bb1 --- /dev/null +++ b/packages/docs/zh/api/interfaces/NavigationGuard.md @@ -0,0 +1,28 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / NavigationGuard + +# Interface: NavigationGuard + +## Callable %{#Callable}% + +### NavigationGuard %{#Callable-NavigationGuard}% + +▸ **NavigationGuard**(`to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> + +Navigation guard. See [Navigation +Guards](/guide/advanced/navigation-guards.md). + +#### Parameters %{#Callable-NavigationGuard-Parameters}% + +| Name | Type | +| :------ | :------ | +| `to` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | +| `from` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | +| `next` | [`NavigationGuardNext`](NavigationGuardNext.md) | + +#### Returns %{#Callable-NavigationGuard-Returns}% + +`NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> diff --git a/packages/docs/zh/api/interfaces/NavigationGuardNext.md b/packages/docs/zh/api/interfaces/NavigationGuardNext.md new file mode 100644 index 00000000..278770b6 --- /dev/null +++ b/packages/docs/zh/api/interfaces/NavigationGuardNext.md @@ -0,0 +1,73 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / NavigationGuardNext + +# Interface: NavigationGuardNext + +## Callable %{#Callable}% + +### NavigationGuardNext %{#Callable-NavigationGuardNext}% + +▸ **NavigationGuardNext**(): `void` + +#### Returns %{#Callable-NavigationGuardNext-Returns}% + +`void` + +### NavigationGuardNext %{#Callable-NavigationGuardNext_1}% + +▸ **NavigationGuardNext**(`error`): `void` + +#### Parameters %{#Callable-NavigationGuardNext-Parameters}% + +| Name | Type | +| :------ | :------ | +| `error` | `Error` | + +#### Returns %{#Callable-NavigationGuardNext-Returns_1}% + +`void` + +### NavigationGuardNext %{#Callable-NavigationGuardNext_2}% + +▸ **NavigationGuardNext**(`location`): `void` + +#### Parameters %{#Callable-NavigationGuardNext-Parameters_1}% + +| Name | Type | +| :------ | :------ | +| `location` | [`RouteLocationRaw`](../index.md#routelocationraw) | + +#### Returns %{#Callable-NavigationGuardNext-Returns_2}% + +`void` + +### NavigationGuardNext %{#Callable-NavigationGuardNext_3}% + +▸ **NavigationGuardNext**(`valid`): `void` + +#### Parameters %{#Callable-NavigationGuardNext-Parameters_2}% + +| Name | Type | +| :------ | :------ | +| `valid` | `undefined` \| `boolean` | + +#### Returns %{#Callable-NavigationGuardNext-Returns_3}% + +`void` + +### NavigationGuardNext %{#Callable-NavigationGuardNext_4}% + +▸ **NavigationGuardNext**(`cb`): `void` + +#### Parameters %{#Callable-NavigationGuardNext-Parameters_3}% + +| Name | Type | +| :------ | :------ | +| `cb` | `NavigationGuardNextCallback` | + +#### Returns %{#Callable-NavigationGuardNext-Returns_4}% + +`void` diff --git a/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md b/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md new file mode 100644 index 00000000..2799f4d1 --- /dev/null +++ b/packages/docs/zh/api/interfaces/NavigationGuardWithThis.md @@ -0,0 +1,35 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / NavigationGuardWithThis + +# Interface: NavigationGuardWithThis + +## Type parameters %{#Type-parameters}% + +| Name | +| :------ | +| `T` | + +## Callable %{#Callable}% + +### NavigationGuardWithThis %{#Callable-NavigationGuardWithThis}% + +▸ **NavigationGuardWithThis**(`this`, `to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> + +Navigation guard. See [Navigation +Guards](/guide/advanced/navigation-guards.md). + +#### Parameters %{#Callable-NavigationGuardWithThis-Parameters}% + +| Name | Type | +| :------ | :------ | +| `this` | `T` | +| `to` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | +| `from` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | +| `next` | [`NavigationGuardNext`](NavigationGuardNext.md) | + +#### Returns %{#Callable-NavigationGuardWithThis-Returns}% + +`NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> diff --git a/packages/docs/zh/api/interfaces/NavigationHookAfter.md b/packages/docs/zh/api/interfaces/NavigationHookAfter.md new file mode 100644 index 00000000..34fe56b2 --- /dev/null +++ b/packages/docs/zh/api/interfaces/NavigationHookAfter.md @@ -0,0 +1,25 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / NavigationHookAfter + +# Interface: NavigationHookAfter + +## Callable %{#Callable}% + +### NavigationHookAfter %{#Callable-NavigationHookAfter}% + +▸ **NavigationHookAfter**(`to`, `from`, `failure?`): `any` + +#### Parameters %{#Callable-NavigationHookAfter-Parameters}% + +| Name | Type | +| :------ | :------ | +| `to` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | +| `from` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | +| `failure?` | `void` \| [`NavigationFailure`](NavigationFailure.md) | + +#### Returns %{#Callable-NavigationHookAfter-Returns}% + +`any` diff --git a/packages/docs/zh/api/interfaces/RouteLocation.md b/packages/docs/zh/api/interfaces/RouteLocation.md new file mode 100644 index 00000000..9a23955a --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteLocation.md @@ -0,0 +1,123 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteLocation + +# Interface: RouteLocation + +[RouteLocationRaw](../index.md#routelocationraw) resolved using the matcher + +## Hierarchy %{#Hierarchy}% + +- `_RouteLocationBase` + + ↳ **`RouteLocation`** + +## Properties %{#Properties}% + +### fullPath %{#Properties-fullPath}% + +• **fullPath**: `string` + +The whole location including the `search` and `hash`. This string is +percentage encoded. + +#### Inherited from %{#Properties-fullPath-Inherited-from}% + +\_RouteLocationBase.fullPath + +___ + +### hash %{#Properties-hash}% + +• **hash**: `string` + +Hash of the current location. If present, starts with a `#`. + +#### Inherited from %{#Properties-hash-Inherited-from}% + +\_RouteLocationBase.hash + +___ + +### matched %{#Properties-matched}% + +• **matched**: [`RouteRecordNormalized`](RouteRecordNormalized.md)[] + +Array of [RouteRecord](../index.md#routerecord) containing components as they were +passed when adding records. It can also contain redirect records. This +can't be used directly + +___ + +### meta %{#Properties-meta}% + +• **meta**: [`RouteMeta`](RouteMeta.md) + +Merged `meta` properties from all the matched route records. + +#### Inherited from %{#Properties-meta-Inherited-from}% + +\_RouteLocationBase.meta + +___ + +### name %{#Properties-name}% + +• **name**: `undefined` \| ``null`` \| [`RouteRecordName`](../index.md#routerecordname) + +Name of the matched record + +#### Inherited from %{#Properties-name-Inherited-from}% + +\_RouteLocationBase.name + +___ + +### params %{#Properties-params}% + +• **params**: [`RouteParams`](../index.md#routeparams) + +Object of decoded params extracted from the `path`. + +#### Inherited from %{#Properties-params-Inherited-from}% + +\_RouteLocationBase.params + +___ + +### path %{#Properties-path}% + +• **path**: `string` + +Percentage encoded pathname section of the URL. + +#### Inherited from %{#Properties-path-Inherited-from}% + +\_RouteLocationBase.path + +___ + +### query %{#Properties-query}% + +• **query**: [`LocationQuery`](../index.md#locationquery) + +Object representation of the `search` property of the current location. + +#### Inherited from %{#Properties-query-Inherited-from}% + +\_RouteLocationBase.query + +___ + +### redirectedFrom %{#Properties-redirectedFrom}% + +• **redirectedFrom**: `undefined` \| [`RouteLocation`](RouteLocation.md) + +Contains the location we were initially trying to access before ending up +on the current location. + +#### Inherited from %{#Properties-redirectedFrom-Inherited-from}% + +\_RouteLocationBase.redirectedFrom diff --git a/packages/docs/zh/api/interfaces/RouteLocationMatched.md b/packages/docs/zh/api/interfaces/RouteLocationMatched.md new file mode 100644 index 00000000..446feb12 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteLocationMatched.md @@ -0,0 +1,142 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteLocationMatched + +# Interface: RouteLocationMatched + +Normalized version of a [route record](../index.md#routerecord). + +## Hierarchy %{#Hierarchy}% + +- [`RouteRecordNormalized`](RouteRecordNormalized.md) + + ↳ **`RouteLocationMatched`** + +## Properties %{#Properties}% + +### aliasOf %{#Properties-aliasOf}% + +• **aliasOf**: `undefined` \| [`RouteRecordNormalized`](RouteRecordNormalized.md) + +Defines if this record is the alias of another one. This property is +`undefined` if the record is the original one. + +#### Inherited from %{#Properties-aliasOf-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[aliasOf](RouteRecordNormalized.md#aliasof) + +___ + +### beforeEnter %{#Properties-beforeEnter}% + +• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] + +Registered beforeEnter guards + +#### Inherited from %{#Properties-beforeEnter-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[beforeEnter](RouteRecordNormalized.md#beforeenter) + +___ + +### children %{#Properties-children}% + +• **children**: [`RouteRecordRaw`](../index.md#routerecordraw)[] + +Nested route records. + +#### Inherited from %{#Properties-children-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[children](RouteRecordNormalized.md#children) + +___ + +### components %{#Properties-components}% + +• **components**: `undefined` \| ``null`` \| `Record`<`string`, [`RouteComponent`](../index.md#routecomponent)\> + +{@inheritDoc RouteRecordMultipleViews.components} + +#### Overrides %{#Properties-components-Overrides}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[components](RouteRecordNormalized.md#components) + +___ + +### instances %{#Properties-instances}% + +• **instances**: `Record`<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`<{}, {}, {}, {}, {}, {}, {}, {}, ``false``, `ComponentOptionsBase`<`any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, {}, {}, `string`\>, {}\>\> + +Mounted route component instances +Having the instances on the record mean beforeRouteUpdate and +beforeRouteLeave guards can only be invoked with the latest mounted app +instance if there are multiple application instances rendering the same +view, basically duplicating the content on the page, which shouldn't happen +in practice. It will work if multiple apps are rendering different named +views. + +#### Inherited from %{#Properties-instances-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[instances](RouteRecordNormalized.md#instances) + +___ + +### meta %{#Properties-meta}% + +• **meta**: [`RouteMeta`](RouteMeta.md) + +{@inheritDoc _RouteRecordBase.meta} + +#### Inherited from %{#Properties-meta-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[meta](RouteRecordNormalized.md#meta) + +___ + +### name %{#Properties-name}% + +• **name**: `undefined` \| [`RouteRecordName`](../index.md#routerecordname) + +{@inheritDoc _RouteRecordBase.name} + +#### Inherited from %{#Properties-name-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[name](RouteRecordNormalized.md#name) + +___ + +### path %{#Properties-path}% + +• **path**: `string` + +{@inheritDoc _RouteRecordBase.path} + +#### Inherited from %{#Properties-path-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[path](RouteRecordNormalized.md#path) + +___ + +### props %{#Properties-props}% + +• **props**: `Record`<`string`, `_RouteRecordProps`\> + +{@inheritDoc RouteRecordMultipleViews.props} + +#### Inherited from %{#Properties-props-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[props](RouteRecordNormalized.md#props) + +___ + +### redirect %{#Properties-redirect}% + +• **redirect**: `undefined` \| `RouteRecordRedirectOption` + +{@inheritDoc _RouteRecordBase.redirect} + +#### Inherited from %{#Properties-redirect-Inherited-from}% + +[RouteRecordNormalized](RouteRecordNormalized.md).[redirect](RouteRecordNormalized.md#redirect) diff --git a/packages/docs/zh/api/interfaces/RouteLocationNormalized.md b/packages/docs/zh/api/interfaces/RouteLocationNormalized.md new file mode 100644 index 00000000..2e49471d --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteLocationNormalized.md @@ -0,0 +1,122 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteLocationNormalized + +# Interface: RouteLocationNormalized + +Similar to [RouteLocation](RouteLocation.md) but its +[matched](RouteLocationNormalized.md#matched) cannot contain redirect records + +## Hierarchy %{#Hierarchy}% + +- `_RouteLocationBase` + + ↳ **`RouteLocationNormalized`** + +## Properties %{#Properties}% + +### fullPath %{#Properties-fullPath}% + +• **fullPath**: `string` + +The whole location including the `search` and `hash`. This string is +percentage encoded. + +#### Inherited from %{#Properties-fullPath-Inherited-from}% + +\_RouteLocationBase.fullPath + +___ + +### hash %{#Properties-hash}% + +• **hash**: `string` + +Hash of the current location. If present, starts with a `#`. + +#### Inherited from %{#Properties-hash-Inherited-from}% + +\_RouteLocationBase.hash + +___ + +### matched %{#Properties-matched}% + +• **matched**: [`RouteRecordNormalized`](RouteRecordNormalized.md)[] + +Array of [RouteRecordNormalized](RouteRecordNormalized.md) + +___ + +### meta %{#Properties-meta}% + +• **meta**: [`RouteMeta`](RouteMeta.md) + +Merged `meta` properties from all the matched route records. + +#### Inherited from %{#Properties-meta-Inherited-from}% + +\_RouteLocationBase.meta + +___ + +### name %{#Properties-name}% + +• **name**: `undefined` \| ``null`` \| [`RouteRecordName`](../index.md#routerecordname) + +Name of the matched record + +#### Inherited from %{#Properties-name-Inherited-from}% + +\_RouteLocationBase.name + +___ + +### params %{#Properties-params}% + +• **params**: [`RouteParams`](../index.md#routeparams) + +Object of decoded params extracted from the `path`. + +#### Inherited from %{#Properties-params-Inherited-from}% + +\_RouteLocationBase.params + +___ + +### path %{#Properties-path}% + +• **path**: `string` + +Percentage encoded pathname section of the URL. + +#### Inherited from %{#Properties-path-Inherited-from}% + +\_RouteLocationBase.path + +___ + +### query %{#Properties-query}% + +• **query**: [`LocationQuery`](../index.md#locationquery) + +Object representation of the `search` property of the current location. + +#### Inherited from %{#Properties-query-Inherited-from}% + +\_RouteLocationBase.query + +___ + +### redirectedFrom %{#Properties-redirectedFrom}% + +• **redirectedFrom**: `undefined` \| [`RouteLocation`](RouteLocation.md) + +Contains the location we were initially trying to access before ending up +on the current location. + +#### Inherited from %{#Properties-redirectedFrom-Inherited-from}% + +\_RouteLocationBase.redirectedFrom diff --git a/packages/docs/zh/api/interfaces/RouteLocationNormalizedLoaded.md b/packages/docs/zh/api/interfaces/RouteLocationNormalizedLoaded.md new file mode 100644 index 00000000..0f3b828a --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteLocationNormalizedLoaded.md @@ -0,0 +1,124 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteLocationNormalizedLoaded + +# Interface: RouteLocationNormalizedLoaded + +[RouteLocationRaw](../index.md#routelocationraw) with + +## Hierarchy %{#Hierarchy}% + +- `_RouteLocationBase` + + ↳ **`RouteLocationNormalizedLoaded`** + +## Properties %{#Properties}% + +### fullPath %{#Properties-fullPath}% + +• **fullPath**: `string` + +The whole location including the `search` and `hash`. This string is +percentage encoded. + +#### Inherited from %{#Properties-fullPath-Inherited-from}% + +\_RouteLocationBase.fullPath + +___ + +### hash %{#Properties-hash}% + +• **hash**: `string` + +Hash of the current location. If present, starts with a `#`. + +#### Inherited from %{#Properties-hash-Inherited-from}% + +\_RouteLocationBase.hash + +___ + +### matched %{#Properties-matched}% + +• **matched**: [`RouteLocationMatched`](RouteLocationMatched.md)[] + +Array of [RouteLocationMatched](RouteLocationMatched.md) containing only plain components (any +lazy-loaded components have been loaded and were replaced inside the +`components` object) so it can be directly used to display routes. It +cannot contain redirect records either + +___ + +### meta %{#Properties-meta}% + +• **meta**: [`RouteMeta`](RouteMeta.md) + +Merged `meta` properties from all the matched route records. + +#### Inherited from %{#Properties-meta-Inherited-from}% + +\_RouteLocationBase.meta + +___ + +### name %{#Properties-name}% + +• **name**: `undefined` \| ``null`` \| [`RouteRecordName`](../index.md#routerecordname) + +Name of the matched record + +#### Inherited from %{#Properties-name-Inherited-from}% + +\_RouteLocationBase.name + +___ + +### params %{#Properties-params}% + +• **params**: [`RouteParams`](../index.md#routeparams) + +Object of decoded params extracted from the `path`. + +#### Inherited from %{#Properties-params-Inherited-from}% + +\_RouteLocationBase.params + +___ + +### path %{#Properties-path}% + +• **path**: `string` + +Percentage encoded pathname section of the URL. + +#### Inherited from %{#Properties-path-Inherited-from}% + +\_RouteLocationBase.path + +___ + +### query %{#Properties-query}% + +• **query**: [`LocationQuery`](../index.md#locationquery) + +Object representation of the `search` property of the current location. + +#### Inherited from %{#Properties-query-Inherited-from}% + +\_RouteLocationBase.query + +___ + +### redirectedFrom %{#Properties-redirectedFrom}% + +• **redirectedFrom**: `undefined` \| [`RouteLocation`](RouteLocation.md) + +Contains the location we were initially trying to access before ending up +on the current location. + +#### Inherited from %{#Properties-redirectedFrom-Inherited-from}% + +\_RouteLocationBase.redirectedFrom diff --git a/packages/docs/zh/api/interfaces/RouteLocationOptions.md b/packages/docs/zh/api/interfaces/RouteLocationOptions.md new file mode 100644 index 00000000..488dc576 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteLocationOptions.md @@ -0,0 +1,37 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteLocationOptions + +# Interface: RouteLocationOptions + +Common options for all navigation methods. + +## Properties %{#Properties}% + +### force %{#Properties-force}% + +• `Optional` **force**: `boolean` + +Triggers the navigation even if the location is the same as the current one. +Note this will also add a new entry to the history unless `replace: true` +is passed. + +___ + +### replace %{#Properties-replace}% + +• `Optional` **replace**: `boolean` + +Replace the entry in the history instead of pushing a new entry + +___ + +### state %{#Properties-state}% + +• `Optional` **state**: [`HistoryState`](HistoryState.md) + +State to save using the History API. This cannot contain any reactive +values and some primitives like Symbols are forbidden. More info at +https://developer.mozilla.org/en-US/docs/Web/API/History/state diff --git a/packages/docs/zh/api/interfaces/RouteMeta.md b/packages/docs/zh/api/interfaces/RouteMeta.md new file mode 100644 index 00000000..344ab4ab --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteMeta.md @@ -0,0 +1,28 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteMeta + +# Interface: RouteMeta + +Interface to type `meta` fields in route records. + +**`Example`** + +```ts +// typings.d.ts or router.ts +import 'vue-router'; + +declare module 'vue-router' { + interface RouteMeta { + requiresAuth?: boolean + } + } +``` + +## Hierarchy %{#Hierarchy}% + +- `Record`<`string` \| `number` \| `symbol`, `unknown`\> + + ↳ **`RouteMeta`** diff --git a/packages/docs/zh/api/interfaces/RouteRecordNormalized.md b/packages/docs/zh/api/interfaces/RouteRecordNormalized.md new file mode 100644 index 00000000..a2a800b9 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouteRecordNormalized.md @@ -0,0 +1,102 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouteRecordNormalized + +# Interface: RouteRecordNormalized + +Normalized version of a [route record](../index.md#routerecord). + +## Hierarchy %{#Hierarchy}% + +- **`RouteRecordNormalized`** + + ↳ [`RouteLocationMatched`](RouteLocationMatched.md) + +## Properties %{#Properties}% + +### aliasOf %{#Properties-aliasOf}% + +• **aliasOf**: `undefined` \| [`RouteRecordNormalized`](RouteRecordNormalized.md) + +Defines if this record is the alias of another one. This property is +`undefined` if the record is the original one. + +___ + +### beforeEnter %{#Properties-beforeEnter}% + +• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] + +Registered beforeEnter guards + +___ + +### children %{#Properties-children}% + +• **children**: [`RouteRecordRaw`](../index.md#routerecordraw)[] + +Nested route records. + +___ + +### components %{#Properties-components}% + +• **components**: `undefined` \| ``null`` \| `Record`<`string`, `RawRouteComponent`\> + +{@inheritDoc RouteRecordMultipleViews.components} + +___ + +### instances %{#Properties-instances}% + +• **instances**: `Record`<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`<{}, {}, {}, {}, {}, {}, {}, {}, ``false``, `ComponentOptionsBase`<`any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`, {}, {}, `string`\>, {}\>\> + +Mounted route component instances +Having the instances on the record mean beforeRouteUpdate and +beforeRouteLeave guards can only be invoked with the latest mounted app +instance if there are multiple application instances rendering the same +view, basically duplicating the content on the page, which shouldn't happen +in practice. It will work if multiple apps are rendering different named +views. + +___ + +### meta %{#Properties-meta}% + +• **meta**: [`RouteMeta`](RouteMeta.md) + +{@inheritDoc _RouteRecordBase.meta} + +___ + +### name %{#Properties-name}% + +• **name**: `undefined` \| [`RouteRecordName`](../index.md#routerecordname) + +{@inheritDoc _RouteRecordBase.name} + +___ + +### path %{#Properties-path}% + +• **path**: `string` + +{@inheritDoc _RouteRecordBase.path} + +___ + +### props %{#Properties-props}% + +• **props**: `Record`<`string`, `_RouteRecordProps`\> + +{@inheritDoc RouteRecordMultipleViews.props} + +___ + +### redirect %{#Properties-redirect}% + +• **redirect**: `undefined` \| `RouteRecordRedirectOption` + +{@inheritDoc _RouteRecordBase.redirect} diff --git a/packages/docs/zh/api/interfaces/Router.md b/packages/docs/zh/api/interfaces/Router.md new file mode 100644 index 00000000..baec77e9 --- /dev/null +++ b/packages/docs/zh/api/interfaces/Router.md @@ -0,0 +1,413 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / Router + +# Interface: Router + +Router instance. + +## Properties %{#Properties}% + +### currentRoute %{#Properties-currentRoute}% + +• `Readonly` **currentRoute**: `Ref`<[`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md)\> + +Current [RouteLocationNormalized](RouteLocationNormalized.md) + +___ + +### listening %{#Properties-listening}% + +• **listening**: `boolean` + +Allows turning off the listening of history events. This is a low level api for micro-frontends. + +___ + +### options %{#Properties-options}% + +• `Readonly` **options**: [`RouterOptions`](RouterOptions.md) + +Original options object passed to create the Router + +## Methods %{#Methods}% + +### addRoute %{#Methods-addRoute}% + +▸ **addRoute**(`parentName`, `route`): () => `void` + +Add a new [route record](../index.md#routerecordraw) as the child of an existing route. + +#### Parameters %{#Methods-addRoute-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `parentName` | [`RouteRecordName`](../index.md#routerecordname) | Parent Route Record where `route` should be appended at | +| `route` | [`RouteRecordRaw`](../index.md#routerecordraw) | Route Record to add | + +#### Returns %{#Methods-addRoute-Returns}% + +`fn` + +▸ (): `void` + +Add a new [route record](../index.md#routerecordraw) as the child of an existing route. + +##### Returns %{#Methods-addRoute-Returns-Returns}% + +`void` + +▸ **addRoute**(`route`): () => `void` + +Add a new [route record](../index.md#routerecordraw) to the router. + +#### Parameters %{#Methods-addRoute-Parameters_1}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `route` | [`RouteRecordRaw`](../index.md#routerecordraw) | Route Record to add | + +#### Returns %{#Methods-addRoute-Returns_1}% + +`fn` + +▸ (): `void` + +Add a new [route record](../index.md#routerecordraw) to the router. + +##### Returns %{#Methods-addRoute-Returns-Returns_1}% + +`void` + +___ + +### afterEach %{#Methods-afterEach}% + +▸ **afterEach**(`guard`): () => `void` + +Add a navigation hook that is executed after every navigation. Returns a +function that removes the registered hook. + +**`Example`** + +```js +router.afterEach((to, from, failure) => { + if (isNavigationFailure(failure)) { + console.log('failed navigation', failure) + } +}) +``` + +#### Parameters %{#Methods-afterEach-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `guard` | [`NavigationHookAfter`](NavigationHookAfter.md) | navigation hook to add | + +#### Returns %{#Methods-afterEach-Returns}% + +`fn` + +▸ (): `void` + +Add a navigation hook that is executed after every navigation. Returns a +function that removes the registered hook. + +**`Example`** + +```js +router.afterEach((to, from, failure) => { + if (isNavigationFailure(failure)) { + console.log('failed navigation', failure) + } +}) +``` + +##### Returns %{#Methods-afterEach-Returns-Returns}% + +`void` + +___ + +### back %{#Methods-back}% + +▸ **back**(): `void` + +Go back in history if possible by calling `history.back()`. Equivalent to +`router.go(-1)`. + +#### Returns %{#Methods-back-Returns}% + +`void` + +___ + +### beforeEach %{#Methods-beforeEach}% + +▸ **beforeEach**(`guard`): () => `void` + +Add a navigation guard that executes before any navigation. Returns a +function that removes the registered guard. + +#### Parameters %{#Methods-beforeEach-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> | navigation guard to add | + +#### Returns %{#Methods-beforeEach-Returns}% + +`fn` + +▸ (): `void` + +Add a navigation guard that executes before any navigation. Returns a +function that removes the registered guard. + +##### Returns %{#Methods-beforeEach-Returns-Returns}% + +`void` + +___ + +### beforeResolve %{#Methods-beforeResolve}% + +▸ **beforeResolve**(`guard`): () => `void` + +Add a navigation guard that executes before navigation is about to be +resolved. At this state all component have been fetched and other +navigation guards have been successful. Returns a function that removes the +registered guard. + +**`Example`** + +```js +router.beforeResolve(to => { + if (to.meta.requiresAuth && !isAuthenticated) return false +}) +``` + +#### Parameters %{#Methods-beforeResolve-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> | navigation guard to add | + +#### Returns %{#Methods-beforeResolve-Returns}% + +`fn` + +▸ (): `void` + +Add a navigation guard that executes before navigation is about to be +resolved. At this state all component have been fetched and other +navigation guards have been successful. Returns a function that removes the +registered guard. + +**`Example`** + +```js +router.beforeResolve(to => { + if (to.meta.requiresAuth && !isAuthenticated) return false +}) +``` + +##### Returns %{#Methods-beforeResolve-Returns-Returns}% + +`void` + +___ + +### forward %{#Methods-forward}% + +▸ **forward**(): `void` + +Go forward in history if possible by calling `history.forward()`. +Equivalent to `router.go(1)`. + +#### Returns %{#Methods-forward-Returns}% + +`void` + +___ + +### getRoutes %{#Methods-getRoutes}% + +▸ **getRoutes**(): [`RouteRecordNormalized`](RouteRecordNormalized.md)[] + +Get a full list of all the [route records](../index.md#routerecord). + +#### Returns %{#Methods-getRoutes-Returns}% + +[`RouteRecordNormalized`](RouteRecordNormalized.md)[] + +___ + +### go %{#Methods-go}% + +▸ **go**(`delta`): `void` + +Allows you to move forward or backward through the history. Calls +`history.go()`. + +#### Parameters %{#Methods-go-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `delta` | `number` | The position in the history to which you want to move, relative to the current page | + +#### Returns %{#Methods-go-Returns}% + +`void` + +___ + +### hasRoute %{#Methods-hasRoute}% + +▸ **hasRoute**(`name`): `boolean` + +Checks if a route with a given name exists + +#### Parameters %{#Methods-hasRoute-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `name` | [`RouteRecordName`](../index.md#routerecordname) | Name of the route to check | + +#### Returns %{#Methods-hasRoute-Returns}% + +`boolean` + +___ + +### isReady %{#Methods-isReady}% + +▸ **isReady**(): `Promise`<`void`\> + +Returns a Promise that resolves when the router has completed the initial +navigation, which means it has resolved all async enter hooks and async +components that are associated with the initial route. If the initial +navigation already happened, the promise resolves immediately. + +This is useful in server-side rendering to ensure consistent output on both +the server and the client. Note that on server side, you need to manually +push the initial location while on client side, the router automatically +picks it up from the URL. + +#### Returns %{#Methods-isReady-Returns}% + +`Promise`<`void`\> + +___ + +### onError %{#Methods-onError}% + +▸ **onError**(`handler`): () => `void` + +Adds an error handler that is called every time a non caught error happens +during navigation. This includes errors thrown synchronously and +asynchronously, errors returned or passed to `next` in any navigation +guard, and errors occurred when trying to resolve an async component that +is required to render a route. + +#### Parameters %{#Methods-onError-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `handler` | `_ErrorHandler` | error handler to register | + +#### Returns %{#Methods-onError-Returns}% + +`fn` + +▸ (): `void` + +Adds an error handler that is called every time a non caught error happens +during navigation. This includes errors thrown synchronously and +asynchronously, errors returned or passed to `next` in any navigation +guard, and errors occurred when trying to resolve an async component that +is required to render a route. + +##### Returns %{#Methods-onError-Returns-Returns}% + +`void` + +___ + +### push %{#Methods-push}% + +▸ **push**(`to`): `Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> + +Programmatically navigate to a new URL by pushing an entry in the history +stack. + +#### Parameters %{#Methods-push-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `to` | [`RouteLocationRaw`](../index.md#routelocationraw) | Route location to navigate to | + +#### Returns %{#Methods-push-Returns}% + +`Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> + +___ + +### removeRoute %{#Methods-removeRoute}% + +▸ **removeRoute**(`name`): `void` + +Remove an existing route by its name. + +#### Parameters %{#Methods-removeRoute-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `name` | [`RouteRecordName`](../index.md#routerecordname) | Name of the route to remove | + +#### Returns %{#Methods-removeRoute-Returns}% + +`void` + +___ + +### replace %{#Methods-replace}% + +▸ **replace**(`to`): `Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> + +Programmatically navigate to a new URL by replacing the current entry in +the history stack. + +#### Parameters %{#Methods-replace-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `to` | [`RouteLocationRaw`](../index.md#routelocationraw) | Route location to navigate to | + +#### Returns %{#Methods-replace-Returns}% + +`Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> + +___ + +### resolve %{#Methods-resolve}% + +▸ **resolve**(`to`, `currentLocation?`): [`RouteLocation`](RouteLocation.md) & { `href`: `string` } + +Returns the [normalized version](RouteLocation.md) of a +[route location](../index.md#routelocationraw). Also includes an `href` property +that includes any existing `base`. By default, the `currentLocation` used is +`router.currentRoute` and should only be overridden in advanced use cases. + +#### Parameters %{#Methods-resolve-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `to` | [`RouteLocationRaw`](../index.md#routelocationraw) | Raw route location to resolve | +| `currentLocation?` | [`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md) | Optional current location to resolve against | + +#### Returns %{#Methods-resolve-Returns}% + +[`RouteLocation`](RouteLocation.md) & { `href`: `string` } diff --git a/packages/docs/zh/api/interfaces/RouterHistory.md b/packages/docs/zh/api/interfaces/RouterHistory.md new file mode 100644 index 00000000..7349c181 --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouterHistory.md @@ -0,0 +1,168 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouterHistory + +# Interface: RouterHistory + +Interface implemented by History implementations that can be passed to the +router as Router.history + +## Properties %{#Properties}% + +### base %{#Properties-base}% + +• `Readonly` **base**: `string` + +Base path that is prepended to every url. This allows hosting an SPA at a +sub-folder of a domain like `example.com/sub-folder` by having a `base` of +`/sub-folder` + +___ + +### location %{#Properties-location}% + +• `Readonly` **location**: `string` + +Current History location + +___ + +### state %{#Properties-state}% + +• `Readonly` **state**: [`HistoryState`](HistoryState.md) + +Current History state + +## Methods %{#Methods}% + +### createHref %{#Methods-createHref}% + +▸ **createHref**(`location`): `string` + +Generates the corresponding href to be used in an anchor tag. + +#### Parameters %{#Methods-createHref-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `location` | `string` | history location that should create an href | + +#### Returns %{#Methods-createHref-Returns}% + +`string` + +___ + +### destroy %{#Methods-destroy}% + +▸ **destroy**(): `void` + +Clears any event listener attached by the history implementation. + +#### Returns %{#Methods-destroy-Returns}% + +`void` + +___ + +### go %{#Methods-go}% + +▸ **go**(`delta`, `triggerListeners?`): `void` + +Traverses history in a given direction. + +**`Example`** + +```js +myHistory.go(-1) // equivalent to window.history.back() +myHistory.go(1) // equivalent to window.history.forward() +``` + +#### Parameters %{#Methods-go-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `delta` | `number` | distance to travel. If delta is \< 0, it will go back, if it's \> 0, it will go forward by that amount of entries. | +| `triggerListeners?` | `boolean` | whether this should trigger listeners attached to the history | + +#### Returns %{#Methods-go-Returns}% + +`void` + +___ + +### listen %{#Methods-listen}% + +▸ **listen**(`callback`): () => `void` + +Attach a listener to the History implementation that is triggered when the +navigation is triggered from outside (like the Browser back and forward +buttons) or when passing `true` to RouterHistory.back and +RouterHistory.forward + +#### Parameters %{#Methods-listen-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `callback` | `NavigationCallback` | listener to attach | + +#### Returns %{#Methods-listen-Returns}% + +`fn` + +a callback to remove the listener + +▸ (): `void` + +Attach a listener to the History implementation that is triggered when the +navigation is triggered from outside (like the Browser back and forward +buttons) or when passing `true` to RouterHistory.back and +RouterHistory.forward + +##### Returns %{#Methods-listen-Returns-Returns}% + +`void` + +a callback to remove the listener + +___ + +### push %{#Methods-push}% + +▸ **push**(`to`, `data?`): `void` + +Navigates to a location. In the case of an HTML5 History implementation, +this will call `history.pushState` to effectively change the URL. + +#### Parameters %{#Methods-push-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `to` | `string` | location to push | +| `data?` | [`HistoryState`](HistoryState.md) | optional [HistoryState](HistoryState.md) to be associated with the navigation entry | + +#### Returns %{#Methods-push-Returns}% + +`void` + +___ + +### replace %{#Methods-replace}% + +▸ **replace**(`to`, `data?`): `void` + +Same as [push](RouterHistory.md#push) but performs a `history.replaceState` +instead of `history.pushState` + +#### Parameters %{#Methods-replace-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `to` | `string` | location to set | +| `data?` | [`HistoryState`](HistoryState.md) | optional [HistoryState](HistoryState.md) to be associated with the navigation entry | + +#### Returns %{#Methods-replace-Returns}% + +`void` diff --git a/packages/docs/zh/api/interfaces/RouterLinkProps.md b/packages/docs/zh/api/interfaces/RouterLinkProps.md new file mode 100644 index 00000000..af43373d --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouterLinkProps.md @@ -0,0 +1,74 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouterLinkProps + +# Interface: RouterLinkProps + +## Hierarchy %{#Hierarchy}% + +- `RouterLinkOptions` + + ↳ **`RouterLinkProps`** + +## Properties %{#Properties}% + +### activeClass %{#Properties-activeClass}% + +• `Optional` **activeClass**: `string` + +Class to apply when the link is active + +___ + +### ariaCurrentValue %{#Properties-ariaCurrentValue}% + +• `Optional` **ariaCurrentValue**: ``"location"`` \| ``"time"`` \| ``"page"`` \| ``"step"`` \| ``"date"`` \| ``"true"`` \| ``"false"`` + +Value passed to the attribute `aria-current` when the link is exact active. + +**`Default Value`** + +`'page'` + +___ + +### custom %{#Properties-custom}% + +• `Optional` **custom**: `boolean` + +Whether RouterLink should not wrap its content in an `a` tag. Useful when +using `v-slot` to create a custom RouterLink + +___ + +### exactActiveClass %{#Properties-exactActiveClass}% + +• `Optional` **exactActiveClass**: `string` + +Class to apply when the link is exact active + +___ + +### replace %{#Properties-replace}% + +• `Optional` **replace**: `boolean` + +Calls `router.replace` instead of `router.push`. + +#### Inherited from %{#Properties-replace-Inherited-from}% + +RouterLinkOptions.replace + +___ + +### to %{#Properties-to}% + +• **to**: [`RouteLocationRaw`](../index.md#routelocationraw) + +Route Location the link should navigate to when clicked on. + +#### Inherited from %{#Properties-to-Inherited-from}% + +RouterLinkOptions.to diff --git a/packages/docs/zh/api/interfaces/RouterOptions.md b/packages/docs/zh/api/interfaces/RouterOptions.md new file mode 100644 index 00000000..2779cb0b --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouterOptions.md @@ -0,0 +1,188 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouterOptions + +# Interface: RouterOptions + +Options to initialize a [Router](Router.md) instance. + +## Hierarchy %{#Hierarchy}% + +- [`PathParserOptions`](../index.md#pathparseroptions) + + ↳ **`RouterOptions`** + +## Properties %{#Properties}% + +### end %{#Properties-end}% + +• `Optional` **end**: `boolean` + +Should the RegExp match until the end by appending a `$` to it. + +**`Default Value`** + +`true` + +#### Inherited from %{#Properties-end-Inherited-from}% + +PathParserOptions.end + +___ + +### history %{#Properties-history}% + +• **history**: [`RouterHistory`](RouterHistory.md) + +History implementation used by the router. Most web applications should use +`createWebHistory` but it requires the server to be properly configured. +You can also use a _hash_ based history with `createWebHashHistory` that +does not require any configuration on the server but isn't handled at all +by search engines and does poorly on SEO. + +**`Example`** + +```js +createRouter({ + history: createWebHistory(), + // other options... +}) +``` + +___ + +### linkActiveClass %{#Properties-linkActiveClass}% + +• `Optional` **linkActiveClass**: `string` + +Default class applied to active [RouterLink](../index.md#routerlink). If none is provided, +`router-link-active` will be applied. + +___ + +### linkExactActiveClass %{#Properties-linkExactActiveClass}% + +• `Optional` **linkExactActiveClass**: `string` + +Default class applied to exact active [RouterLink](../index.md#routerlink). If none is provided, +`router-link-exact-active` will be applied. + +___ + +### parseQuery %{#Properties-parseQuery}% + +• `Optional` **parseQuery**: (`search`: `string`) => [`LocationQuery`](../index.md#locationquery) + +#### Type declaration %{#Properties-parseQuery-Type-declaration}% + +▸ (`search`): [`LocationQuery`](../index.md#locationquery) + +Custom implementation to parse a query. See its counterpart, +[stringifyQuery](RouterOptions.md#stringifyquery). + +**`Example`** + +Let's say you want to use the [qs package](https://github.com/ljharb/qs) +to parse queries, you can provide both `parseQuery` and `stringifyQuery`: +```js +import qs from 'qs' + +createRouter({ + // other options... + parseQuery: qs.parse, + stringifyQuery: qs.stringify, +}) +``` + +##### Parameters %{#Properties-parseQuery-Type-declaration-Parameters}% + +| Name | Type | +| :------ | :------ | +| `search` | `string` | + +##### Returns %{#Properties-parseQuery-Type-declaration-Returns}% + +[`LocationQuery`](../index.md#locationquery) + +___ + +### routes %{#Properties-routes}% + +• **routes**: readonly [`RouteRecordRaw`](../index.md#routerecordraw)[] + +Initial list of routes that should be added to the router. + +___ + +### scrollBehavior %{#Properties-scrollBehavior}% + +• `Optional` **scrollBehavior**: [`RouterScrollBehavior`](RouterScrollBehavior.md) + +Function to control scrolling when navigating between pages. Can return a +Promise to delay scrolling. Check ScrollBehavior. + +**`Example`** + +```js +function scrollBehavior(to, from, savedPosition) { + // `to` and `from` are both route locations + // `savedPosition` can be null if there isn't one +} +``` + +___ + +### sensitive %{#Properties-sensitive}% + +• `Optional` **sensitive**: `boolean` + +Makes the RegExp case-sensitive. + +**`Default Value`** + +`false` + +#### Inherited from %{#Properties-sensitive-Inherited-from}% + +PathParserOptions.sensitive + +___ + +### strict %{#Properties-strict}% + +• `Optional` **strict**: `boolean` + +Whether to disallow a trailing slash or not. + +**`Default Value`** + +`false` + +#### Inherited from %{#Properties-strict-Inherited-from}% + +PathParserOptions.strict + +___ + +### stringifyQuery %{#Properties-stringifyQuery}% + +• `Optional` **stringifyQuery**: (`query`: [`LocationQueryRaw`](../index.md#locationqueryraw)) => `string` + +#### Type declaration %{#Properties-stringifyQuery-Type-declaration}% + +▸ (`query`): `string` + +Custom implementation to stringify a query object. Should not prepend a leading `?`. +[parseQuery](RouterOptions.md#parsequery) counterpart to handle query parsing. + +##### Parameters %{#Properties-stringifyQuery-Type-declaration-Parameters}% + +| Name | Type | +| :------ | :------ | +| `query` | [`LocationQueryRaw`](../index.md#locationqueryraw) | + +##### Returns %{#Properties-stringifyQuery-Type-declaration-Returns}% + +`string` diff --git a/packages/docs/zh/api/interfaces/RouterScrollBehavior.md b/packages/docs/zh/api/interfaces/RouterScrollBehavior.md new file mode 100644 index 00000000..ee3c2aff --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouterScrollBehavior.md @@ -0,0 +1,25 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouterScrollBehavior + +# Interface: RouterScrollBehavior + +## Callable %{#Callable}% + +### RouterScrollBehavior %{#Callable-RouterScrollBehavior}% + +▸ **RouterScrollBehavior**(`to`, `from`, `savedPosition`): `Awaitable`<``false`` \| `void` \| `ScrollPosition`\> + +#### Parameters %{#Callable-RouterScrollBehavior-Parameters}% + +| Name | Type | Description | +| :------ | :------ | :------ | +| `to` | [`RouteLocationNormalized`](RouteLocationNormalized.md) | Route location where we are navigating to | +| `from` | [`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md) | Route location where we are navigating from | +| `savedPosition` | ``null`` \| `_ScrollPositionNormalized` | saved position if it exists, `null` otherwise | + +#### Returns %{#Callable-RouterScrollBehavior-Returns}% + +`Awaitable`<``false`` \| `void` \| `ScrollPosition`\> diff --git a/packages/docs/zh/api/interfaces/RouterViewProps.md b/packages/docs/zh/api/interfaces/RouterViewProps.md new file mode 100644 index 00000000..e5c8034a --- /dev/null +++ b/packages/docs/zh/api/interfaces/RouterViewProps.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[API Documentation](../index.md) / RouterViewProps + +# Interface: RouterViewProps + +## Properties %{#Properties}% + +### name %{#Properties-name}% + +• `Optional` **name**: `string` + +___ + +### route %{#Properties-route}% + +• `Optional` **route**: [`RouteLocationNormalized`](RouteLocationNormalized.md)