From: Eduardo San Martin Morote Date: Mon, 14 Sep 2020 09:56:53 +0000 (+0200) Subject: docs(api): fix links X-Git-Tag: v4.0.0-beta.10~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5a997241cc4f3991ab205011f6a38d3d06a9e5d;p=thirdparty%2Fvuejs%2Frouter.git docs(api): fix links --- diff --git a/docs/api/index.md b/docs/api/index.md index 04c6e503..0b516cd1 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -4,9 +4,6 @@ sidebar: auto # API Reference -- [Interfaces](./vue-router-interface.md) -- [Types](./vue-router-typealias.md) - ## `` Props ### to @@ -813,6 +810,77 @@ Route record that can be provided by the user when adding routes via the [`route - **See Also**: [Meta fields](/guide/advanced/meta.md) +## RouteRecordNormalized + +Normalized version of a [Route Record](#routerecordraw) + +### aliasOf + +- **Type**: `RouteRecordNormalized | undefined` +- **Details**: + + Defines if this record is the alias of another one. This property is `undefined` if the record is the original one. + +### beforeEnter + +- **Type**: [`NavigationGuard`](#navigationguard) +- **Details**: + + Navigation guard applied when entering this record from somewhere else. + +- **See Also**: [Navigation guards](/guide/advanced/navigation-guards.md) + +### children + +- **Type**: Array of normalized [route records](#routerecordnormalized) +- **Details**: + + Children route records of the current route. Empty array if none. + +### components + +- **Type**: `Record` +- **Details**: + + Dictionary of named views, if none, contains an object with the key `default`. + +### meta + +- **Type**: `RouteMeta` +- **Details**: + + Arbitrary data attached to all matched records merged (non recursively) from parent to child. + +- **See also**: [Meta fields](/guide/advanced/meta.md) + +### name + +- **Type**: `string | symbol | undefined` +- **Details**: + + Name for the route record. `undefined` if none was provided. + +### path + +- **Type**: `string` +- **Details**: + + Normalized path of the record. Includes any parent's `path`. + +### props + +- **Type**: `Record>` +- **Details**: + + Dictionary of the [`props` option](#props) for each named view. If none, it will contain only one property named `default`. + +### redirect + +- **Type**: [`RouteLocationRaw`](#routelocationraw) +- **Details**: + + 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. + ## RouteLocationRaw User-level route location that can be passed to `router.push()`, `redirect`, and returned in [Navigation Guards](/guide/advanced/navigation-guards.md). @@ -852,7 +920,10 @@ Normalized route location. Does not have any [redirect records](#routerecordraw) ### matched -Array of [normalized route records](#routerecord). +- **Type**: [`RouteRecordNormalized[]`](#routerecordnormalized) +- **Details**: + + Array of [normalized route records](#routerecord) that were matched with the given route location. ## NavigationFailure diff --git a/docs/api/vue-router-interface.md b/docs/api/vue-router-interface.md deleted file mode 100644 index b766d477..00000000 --- a/docs/api/vue-router-interface.md +++ /dev/null @@ -1,121 +0,0 @@ -# Interface - -## RouteRecordNormalized - -Normalized version of a [Route Record](./vue-router-typealias#routerecord) - -**Signature:** - -```typescript -export interface RouteRecordNormalized -``` - -### Methods - -### Properties - -#### aliasOf - -Defines if this record is the alias of another one. This property is `undefined` if the record is the original one. - -**Signature:** - -```typescript -aliasOf: RouteRecordNormalized | undefined -``` - -#### beforeEnter - -**Signature:** - -```typescript -beforeEnter: RouteRecordMultipleViews['beforeEnter'] -``` - -#### children - -**Signature:** - -```typescript -children: Exclude<_RouteRecordBase['children'], void>; -``` - -#### components - -**Signature:** - -```typescript -components: RouteRecordMultipleViews['components'] -``` - -#### instances - -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. - -**Signature:** - -```typescript -instances: Record; -``` - -#### meta - -Arbitrary data attached to the record. - -**Signature:** - -```typescript -meta: Exclude<_RouteRecordBase['meta'], void>; -``` - -#### name - -Name for the route record. - -**Signature:** - -```typescript -name: _RouteRecordBase['name'] -``` - -#### path - -Path of the record. Should start with `/` unless the record is the child of another record. - -**Signature:** - -```typescript -path: _RouteRecordBase['path'] -``` - -#### props - -**Signature:** - -```typescript -props: Record; -``` - -#### 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. - -**Signature:** - -```typescript -redirect: _RouteRecordBase['redirect'] | undefined -``` - -### Methods - -### Properties - -#### name - -#### route - -## ScrollBehavior_2 - -### Methods - -### Properties diff --git a/docs/api/vue-router-typealias.md b/docs/api/vue-router-typealias.md deleted file mode 100644 index 18441955..00000000 --- a/docs/api/vue-router-typealias.md +++ /dev/null @@ -1,13 +0,0 @@ -# TypeAlias - -## RouteRecord - -Normalized version of a [Route Record](./vue-router-typealias#routerecord) - -**Signature:** - -```typescript -export declare type RouteRecord = RouteRecordNormalized -``` - -## RouteRecordRaw diff --git a/docs/guide/advanced/navigation-guards.md b/docs/guide/advanced/navigation-guards.md index 0ffae4cf..8b422fcf 100644 --- a/docs/guide/advanced/navigation-guards.md +++ b/docs/guide/advanced/navigation-guards.md @@ -86,7 +86,7 @@ router.beforeResolve(async to => { }) ``` -`router.beforeResolve` is the ideal spot to fetch data or do any other operation that you want to avoid doing if the user cannot enter a page. It's also very easy to combine with [`meta` fields](./meta.md) to create a [generic fetching mechanism](#TODO) +`router.beforeResolve` is the ideal spot to fetch data or do any other operation that you want to avoid doing if the user cannot enter a page. It's also very easy to combine with [`meta` fields](./meta.md) to create a [generic fetching mechanism](#TODO). ## Global After Hooks diff --git a/docs/guide/essentials/dynamic-matching.md b/docs/guide/essentials/dynamic-matching.md index f99edfda..ed192b8e 100644 --- a/docs/guide/essentials/dynamic-matching.md +++ b/docs/guide/essentials/dynamic-matching.md @@ -74,16 +74,25 @@ const User = { Regular params will only match characters in between url fragments, separated by `/`. If we want to match **anything**, we can use a custom _param_ regexp by adding the regexp inside parentheses right after the _param_: ```js -{ +const routes = [ // will match everything and put it under `$route.params.pathMatch` - path: '/:pathMatch(.*)' -} -{ + { path: '/:pathMatch(.*)*', name: 'NotFound' }, // will match anything starting with `/user-` and put it under `$route.params.afterUser` - path: '/user-:afterUser(.*)' -} + { path: '/user-:afterUser(.*)' }, +] ``` +In this specific scenario we are using a [custom regexp](/guide/advanced/path-matching.md#custom-regexp) between parentheses and marking the `pathMatch` param as [optionally repeatable](/guide/advanced/path-matching.md#zero-or-more). This is to allows us to directly navigate to the route if we need to by splitting the `path` into an array: + +```js +this.$router.push({ + name: 'NotFound', + params: { pathMatch: this.$route.path.split('/') }, +}) +``` + +See more in the [repeated params](/guide/advanced/path-matching.md#zero-or-more) section. + If you are using [History mode](./history-mode.md), make sure to follow the instructions to correctly configure your server as well. ## Advanced Matching Patterns diff --git a/docs/guide/essentials/navigation.md b/docs/guide/essentials/navigation.md index 3d0fd921..12c89007 100644 --- a/docs/guide/essentials/navigation.md +++ b/docs/guide/essentials/navigation.md @@ -98,4 +98,4 @@ You may have noticed that `router.push`, `router.replace` and `router.go` are co Therefore, if you are already familiar with [Browser History APIs](https://developer.mozilla.org/en-US/docs/Web/API/History_API), manipulating history will feel familiar when using Vue Router. -It is worth mentioning that Vue Router navigation methods (`push`, `replace`, `go`) work consistently no matter the kind of [`history` option](#TODO_api_or_custom_history) is passed when creating the router instance. +It is worth mentioning that Vue Router navigation methods (`push`, `replace`, `go`) work consistently no matter the kind of [`history` option](/api/#history) is passed when creating the router instance. diff --git a/docs/guide/essentials/redirect-and-alias.md b/docs/guide/essentials/redirect-and-alias.md index f44a0029..2b89d718 100644 --- a/docs/guide/essentials/redirect-and-alias.md +++ b/docs/guide/essentials/redirect-and-alias.md @@ -25,12 +25,12 @@ const routes = [ // the function receives the target route as the argument // we return a redirect path/location here. return { path: '/search', query: { q: to.params.searchText } } - } + }, }, { - path: '/search' + path: '/search', // ... - } + }, ] ``` @@ -47,8 +47,8 @@ const routes = [ redirect: to => { // the function receives the target route as the argument // return redirect path/location here. - } - } + }, + }, ] ``` @@ -75,9 +75,9 @@ const routes = [ // - /users // - /users/list // - /people - { path: '', component: UserList, alias: ['/people', 'list'] } - ] - } + { path: '', component: UserList, alias: ['/people', 'list'] }, + ], + }, ] ``` @@ -92,14 +92,10 @@ const routes = [ // - /users/24 // - /users/24/profile // - /24 - { path: 'profile', component: UserDetails, alias: ['/:id', ''] } - ] - } + { path: 'profile', component: UserDetails, alias: ['/:id', ''] }, + ], + }, ] ``` TODO: canonical links in cookbook https://support.google.com/webmasters/answer/139066?hl=en - - - -For advanced usage, check out the [example](https://github.com/vuejs/vue-router/blob/dev/examples/route-alias/app.js). diff --git a/docs/guide/migration/index.md b/docs/guide/migration/index.md index 29de3689..2008d76b 100644 --- a/docs/guide/migration/index.md +++ b/docs/guide/migration/index.md @@ -318,6 +318,10 @@ history.replaceState(history.state, '', url) **Reason**: We use the history state to save information about the navigation like the scroll position, previous location, etc. +### Navigation guards in mixins are ignored + +At the moment navigation guards in mixins are not supported. You can track its support at [vue-router#454](https://github.com/vuejs/vue-router-next/issues/454). + ### TypeScript To make typings more consistent and expressive, some types have been renamed: