diff --git a/packages/docs/api/index.md b/packages/docs/api/index.md index 599abf1e9..f52a63a3c 100644 --- a/packages/docs/api/index.md +++ b/packages/docs/api/index.md @@ -42,7 +42,7 @@ API Documentation ### LocationQuery -Ƭ **LocationQuery**: `Record`<`string`, `LocationQueryValue` \| `LocationQueryValue`[]\> +Ƭ **LocationQuery**: `Record`\<`string`, `LocationQueryValue` \| `LocationQueryValue`[]\> Normalized query object that appears in [RouteLocationNormalized](interfaces/RouteLocationNormalized.md) @@ -50,17 +50,17 @@ ___ ### LocationQueryRaw -Ƭ **LocationQueryRaw**: `Record`<`string` \| `number`, `LocationQueryValueRaw` \| `LocationQueryValueRaw`[]\> +Ƭ **LocationQueryRaw**: `Record`\<`string` \| `number`, `LocationQueryValueRaw` \| `LocationQueryValueRaw`[]\> Loose [LocationQuery](index.md#LocationQuery) object that can be passed to functions like -[push](interfaces/Router.md#push) and [replace](interfaces/Router.md#replace) or anywhere when creating a +[Router.push](interfaces/Router.md#push) and [Router.replace](interfaces/Router.md#replace) or anywhere when creating a [RouteLocationRaw](index.md#RouteLocationRaw) ___ ### PathParserOptions -Ƭ **PathParserOptions**: `Pick`<`_PathParserOptions`, ``"end"`` \| ``"sensitive"`` \| ``"strict"``\> +Ƭ **PathParserOptions**: `Pick`\<`_PathParserOptions`, ``"end"`` \| ``"sensitive"`` \| ``"strict"``\> ___ @@ -82,13 +82,13 @@ ___ ### RouteParams -Ƭ **RouteParams**: `Record`<`string`, `RouteParamValue` \| `RouteParamValue`[]\> +Ƭ **RouteParams**: `Record`\<`string`, `RouteParamValue` \| `RouteParamValue`[]\> ___ ### RouteParamsRaw -Ƭ **RouteParamsRaw**: `Record`<`string`, `RouteParamValueRaw` \| `Exclude`<`RouteParamValueRaw`, ``null`` \| `undefined`\>[]\> +Ƭ **RouteParamsRaw**: `Record`\<`string`, `RouteParamValueRaw` \| `Exclude`\<`RouteParamValueRaw`, ``null`` \| `undefined`\>[]\> ___ @@ -116,7 +116,7 @@ ___ ### UseLinkOptions -Ƭ **UseLinkOptions**: `VueUseOptions`<`RouterLinkOptions`\> +Ƭ **UseLinkOptions**: `VueUseOptions`\<`RouterLinkOptions`\> ## Variables @@ -130,14 +130,24 @@ ___ ### RouterView -• `Const` **RouterView**: () => { `$props`: `AllowedComponentProps` & `ComponentCustomProps` & `VNodeProps` & [`RouterViewProps`](interfaces/RouterViewProps.md) ; `$slots`: { `default?`: (`__namedParameters`: { `Component`: `VNode`<`RendererNode`, `RendererElement`, { `[key: string]`: `any`; }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) }) => `VNode`<`RendererNode`, `RendererElement`, { `[key: string]`: `any`; }\>[] } } +• `Const` **RouterView**: () => \{ `$props`: `AllowedComponentProps` & `ComponentCustomProps` & `VNodeProps` & [`RouterViewProps`](interfaces/RouterViewProps.md) ; `$slots`: \{ `default?`: (`__namedParameters`: \{ `Component`: `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`; }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) }) => `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`; }\>[] } } #### Type declaration -• **new RouterView**() +• **new RouterView**(): `Object` Component to display the current route the user is at. +##### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `$props` | `AllowedComponentProps` & `ComponentCustomProps` & `VNodeProps` & [`RouterViewProps`](interfaces/RouterViewProps.md) | +| `$slots` | \{ `default?`: (`__namedParameters`: \{ `Component`: `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`; }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) }) => `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`; }\>[] } | +| `$slots.default?` | (`__namedParameters`: \{ `Component`: `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`; }\> ; `route`: [`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md) }) => `VNode`\<`RendererNode`, `RendererElement`, \{ `[key: string]`: `any`; }\>[] | + ___ ### START\_LOCATION @@ -308,7 +318,7 @@ ___ ### loadRouteLocation -▸ **loadRouteLocation**(`route`): `Promise`<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\> +▸ **loadRouteLocation**(`route`): `Promise`\<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\> Ensures a route is loaded, so it can be passed as o prop to ``. @@ -320,7 +330,7 @@ Ensures a route is loaded, so it can be passed as o prop to ``. #### Returns -`Promise`<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\> +`Promise`\<[`RouteLocationNormalizedLoaded`](interfaces/RouteLocationNormalizedLoaded.md)\> ___ @@ -372,7 +382,7 @@ ___ | Name | Type | | :------ | :------ | -| `props` | `VueUseOptions`<`RouterLinkOptions`\> | +| `props` | `VueUseOptions`\<`RouterLinkOptions`\> | #### Returns @@ -380,11 +390,11 @@ ___ | Name | Type | | :------ | :------ | -| `href` | `ComputedRef`<`string`\> | -| `isActive` | `ComputedRef`<`boolean`\> | -| `isExactActive` | `ComputedRef`<`boolean`\> | -| `navigate` | (`e`: `MouseEvent`) => `Promise`<`void` \| [`NavigationFailure`](interfaces/NavigationFailure.md)\> | -| `route` | `ComputedRef`<[`RouteLocation`](interfaces/RouteLocation.md) & { `href`: `string` }\> | +| `href` | `ComputedRef`\<`string`\> | +| `isActive` | `ComputedRef`\<`boolean`\> | +| `isExactActive` | `ComputedRef`\<`boolean`\> | +| `navigate` | (`e`: `MouseEvent`) => `Promise`\<`void` \| [`NavigationFailure`](interfaces/NavigationFailure.md)\> | +| `route` | `ComputedRef`\<[`RouteLocation`](interfaces/RouteLocation.md) & \{ `href`: `string` }\> | ___ diff --git a/packages/docs/api/interfaces/NavigationGuard.md b/packages/docs/api/interfaces/NavigationGuard.md index ab2c28093..7a9a4865c 100644 --- a/packages/docs/api/interfaces/NavigationGuard.md +++ b/packages/docs/api/interfaces/NavigationGuard.md @@ -13,7 +13,7 @@ Guards](/guide/advanced/navigation-guards.md). ### NavigationGuard -▸ **NavigationGuard**(`to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> +▸ **NavigationGuard**(`to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\> #### Parameters @@ -25,4 +25,4 @@ Guards](/guide/advanced/navigation-guards.md). #### Returns -`NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> +`NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\> diff --git a/packages/docs/api/interfaces/NavigationGuardWithThis.md b/packages/docs/api/interfaces/NavigationGuardWithThis.md index dc8127fbb..4b4fae7b0 100644 --- a/packages/docs/api/interfaces/NavigationGuardWithThis.md +++ b/packages/docs/api/interfaces/NavigationGuardWithThis.md @@ -4,7 +4,7 @@ editLink: false [API Documentation](../index.md) / NavigationGuardWithThis -# Interface: NavigationGuardWithThis +# Interface: NavigationGuardWithThis\ Navigation guard. See [Navigation Guards](/guide/advanced/navigation-guards.md). @@ -19,7 +19,7 @@ Guards](/guide/advanced/navigation-guards.md). ### NavigationGuardWithThis -▸ **NavigationGuardWithThis**(`this`, `to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> +▸ **NavigationGuardWithThis**(`this`, `to`, `from`, `next`): `NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\> #### Parameters @@ -32,4 +32,4 @@ Guards](/guide/advanced/navigation-guards.md). #### Returns -`NavigationGuardReturn` \| `Promise`<`NavigationGuardReturn`\> +`NavigationGuardReturn` \| `Promise`\<`NavigationGuardReturn`\> diff --git a/packages/docs/api/interfaces/RouteLocationMatched.md b/packages/docs/api/interfaces/RouteLocationMatched.md index 55d6d3319..cf649dd73 100644 --- a/packages/docs/api/interfaces/RouteLocationMatched.md +++ b/packages/docs/api/interfaces/RouteLocationMatched.md @@ -31,7 +31,7 @@ ___ ### beforeEnter -• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Registered beforeEnter guards @@ -55,7 +55,7 @@ ___ ### components -• **components**: `undefined` \| ``null`` \| `Record`<`string`, [`RouteComponent`](../index.md#RouteComponent)\> +• **components**: `undefined` \| ``null`` \| `Record`\<`string`, [`RouteComponent`](../index.md#RouteComponent)\> Components to display when the URL matches this route. Allow using named views. @@ -67,7 +67,7 @@ ___ ### instances -• **instances**: `Record`<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`\> +• **instances**: `Record`\<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`\> Mounted route component instances Having the instances on the record mean beforeRouteUpdate and @@ -122,7 +122,7 @@ ___ ### props -• **props**: `Record`<`string`, `_RouteRecordProps`\> +• **props**: `Record`\<`string`, `_RouteRecordProps`\> Allow passing down params as props to the component rendered by `router-view`. Should be an object with the same keys as `components` or a diff --git a/packages/docs/api/interfaces/RouteLocationNormalized.md b/packages/docs/api/interfaces/RouteLocationNormalized.md index 573380169..43949a3bd 100644 --- a/packages/docs/api/interfaces/RouteLocationNormalized.md +++ b/packages/docs/api/interfaces/RouteLocationNormalized.md @@ -7,7 +7,7 @@ editLink: false # Interface: RouteLocationNormalized Similar to [RouteLocation](RouteLocation.md) but its -[matched](RouteLocationNormalized.md#matched) cannot contain redirect records +[RouteLocationNormalized.matched](RouteLocationNormalized.md#matched) cannot contain redirect records ## Hierarchy diff --git a/packages/docs/api/interfaces/RouteMeta.md b/packages/docs/api/interfaces/RouteMeta.md index 03555d717..5e6007b10 100644 --- a/packages/docs/api/interfaces/RouteMeta.md +++ b/packages/docs/api/interfaces/RouteMeta.md @@ -23,6 +23,6 @@ declare module 'vue-router' { ## Hierarchy -- `Record`<`string` \| `number` \| `symbol`, `unknown`\> +- `Record`\<`string` \| `number` \| `symbol`, `unknown`\> ↳ **`RouteMeta`** diff --git a/packages/docs/api/interfaces/RouteRecordBase.md b/packages/docs/api/interfaces/RouteRecordBase.md index 37754cfa8..f64004047 100644 --- a/packages/docs/api/interfaces/RouteRecordBase.md +++ b/packages/docs/api/interfaces/RouteRecordBase.md @@ -38,7 +38,7 @@ ___ ### beforeEnter -• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Before Enter guard specific to this record. Note `beforeEnter` has no effect if the record has a `redirect` property. @@ -102,7 +102,7 @@ ___ ### props -• `Optional` **props**: `_RouteRecordProps` \| `Record`<`string`, `_RouteRecordProps`\> +• `Optional` **props**: `_RouteRecordProps` \| `Record`\<`string`, `_RouteRecordProps`\> Allow passing down params as props to the component rendered by `router-view`. diff --git a/packages/docs/api/interfaces/RouteRecordMultipleViews.md b/packages/docs/api/interfaces/RouteRecordMultipleViews.md index 93f986c5b..2f5007aa5 100644 --- a/packages/docs/api/interfaces/RouteRecordMultipleViews.md +++ b/packages/docs/api/interfaces/RouteRecordMultipleViews.md @@ -32,7 +32,7 @@ ___ ### beforeEnter -• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Before Enter guard specific to this record. Note `beforeEnter` has no effect if the record has a `redirect` property. @@ -63,7 +63,7 @@ ___ ### components -• **components**: `Record`<`string`, `RawRouteComponent`\> +• **components**: `Record`\<`string`, `RawRouteComponent`\> Components to display when the URL matches this route. Allow using named views. @@ -130,7 +130,7 @@ ___ ### props -• `Optional` **props**: `boolean` \| `Record`<`string`, `_RouteRecordProps`\> +• `Optional` **props**: `boolean` \| `Record`\<`string`, `_RouteRecordProps`\> Allow passing down params as props to the component rendered by `router-view`. Should be an object with the same keys as `components` or a diff --git a/packages/docs/api/interfaces/RouteRecordMultipleViewsWithChildren.md b/packages/docs/api/interfaces/RouteRecordMultipleViewsWithChildren.md index f7f2b2351..ddec0ecaf 100644 --- a/packages/docs/api/interfaces/RouteRecordMultipleViewsWithChildren.md +++ b/packages/docs/api/interfaces/RouteRecordMultipleViewsWithChildren.md @@ -32,7 +32,7 @@ ___ ### beforeEnter -• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Before Enter guard specific to this record. Note `beforeEnter` has no effect if the record has a `redirect` property. @@ -63,7 +63,7 @@ ___ ### components -• `Optional` **components**: ``null`` \| `Record`<`string`, `RawRouteComponent`\> +• `Optional` **components**: ``null`` \| `Record`\<`string`, `RawRouteComponent`\> Components to display when the URL matches this route. Allow using named views. @@ -130,7 +130,7 @@ ___ ### props -• `Optional` **props**: `boolean` \| `Record`<`string`, `_RouteRecordProps`\> +• `Optional` **props**: `boolean` \| `Record`\<`string`, `_RouteRecordProps`\> Allow passing down params as props to the component rendered by `router-view`. Should be an object with the same keys as `components` or a diff --git a/packages/docs/api/interfaces/RouteRecordNormalized.md b/packages/docs/api/interfaces/RouteRecordNormalized.md index fc7dbb891..0107112b6 100644 --- a/packages/docs/api/interfaces/RouteRecordNormalized.md +++ b/packages/docs/api/interfaces/RouteRecordNormalized.md @@ -27,7 +27,7 @@ ___ ### beforeEnter -• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• **beforeEnter**: `undefined` \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Registered beforeEnter guards @@ -43,7 +43,7 @@ ___ ### components -• **components**: `undefined` \| ``null`` \| `Record`<`string`, `RawRouteComponent`\> +• **components**: `undefined` \| ``null`` \| `Record`\<`string`, `RawRouteComponent`\> Components to display when the URL matches this route. Allow using named views. @@ -51,7 +51,7 @@ ___ ### instances -• **instances**: `Record`<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`\> +• **instances**: `Record`\<`string`, `undefined` \| ``null`` \| `ComponentPublicInstance`\> Mounted route component instances Having the instances on the record mean beforeRouteUpdate and @@ -90,7 +90,7 @@ ___ ### props -• **props**: `Record`<`string`, `_RouteRecordProps`\> +• **props**: `Record`\<`string`, `_RouteRecordProps`\> Allow passing down params as props to the component rendered by `router-view`. Should be an object with the same keys as `components` or a diff --git a/packages/docs/api/interfaces/RouteRecordRedirect.md b/packages/docs/api/interfaces/RouteRecordRedirect.md index 5e1496f6c..2f471ddd3 100644 --- a/packages/docs/api/interfaces/RouteRecordRedirect.md +++ b/packages/docs/api/interfaces/RouteRecordRedirect.md @@ -33,7 +33,7 @@ ___ ### beforeEnter -• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Before Enter guard specific to this record. Note `beforeEnter` has no effect if the record has a `redirect` property. diff --git a/packages/docs/api/interfaces/RouteRecordSingleView.md b/packages/docs/api/interfaces/RouteRecordSingleView.md index 3bbb68a6e..9a64196dc 100644 --- a/packages/docs/api/interfaces/RouteRecordSingleView.md +++ b/packages/docs/api/interfaces/RouteRecordSingleView.md @@ -32,7 +32,7 @@ ___ ### beforeEnter -• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Before Enter guard specific to this record. Note `beforeEnter` has no effect if the record has a `redirect` property. diff --git a/packages/docs/api/interfaces/RouteRecordSingleViewWithChildren.md b/packages/docs/api/interfaces/RouteRecordSingleViewWithChildren.md index 67b490cf7..2216c0d92 100644 --- a/packages/docs/api/interfaces/RouteRecordSingleViewWithChildren.md +++ b/packages/docs/api/interfaces/RouteRecordSingleViewWithChildren.md @@ -32,7 +32,7 @@ ___ ### beforeEnter -• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\>[] +• `Optional` **beforeEnter**: [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> \| [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\>[] Before Enter guard specific to this record. Note `beforeEnter` has no effect if the record has a `redirect` property. diff --git a/packages/docs/api/interfaces/Router.md b/packages/docs/api/interfaces/Router.md index ca15e5049..9d7d79933 100644 --- a/packages/docs/api/interfaces/Router.md +++ b/packages/docs/api/interfaces/Router.md @@ -12,7 +12,7 @@ Router instance. ### currentRoute -• `Readonly` **currentRoute**: `Ref`<[`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md)\> +• `Readonly` **currentRoute**: `Ref`\<[`RouteLocationNormalizedLoaded`](RouteLocationNormalizedLoaded.md)\> Current [RouteLocationNormalized](RouteLocationNormalized.md) @@ -159,7 +159,7 @@ function that removes the registered guard. | Name | Type | Description | | :------ | :------ | :------ | -| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> | navigation guard to add | +| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> | navigation guard to add | #### Returns @@ -189,7 +189,7 @@ registered guard. | Name | Type | Description | | :------ | :------ | :------ | -| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)<`undefined`\> | navigation guard to add | +| `guard` | [`NavigationGuardWithThis`](NavigationGuardWithThis.md)\<`undefined`\> | navigation guard to add | #### Returns @@ -292,7 +292,7 @@ ___ ### isReady -▸ **isReady**(): `Promise`<`void`\> +▸ **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 @@ -306,7 +306,7 @@ picks it up from the URL. #### Returns -`Promise`<`void`\> +`Promise`\<`void`\> ___ @@ -346,7 +346,7 @@ ___ ### push -▸ **push**(`to`): `Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> +▸ **push**(`to`): `Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> Programmatically navigate to a new URL by pushing an entry in the history stack. @@ -359,7 +359,7 @@ stack. #### Returns -`Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> +`Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> ___ @@ -383,7 +383,7 @@ ___ ### replace -▸ **replace**(`to`): `Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> +▸ **replace**(`to`): `Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> Programmatically navigate to a new URL by replacing the current entry in the history stack. @@ -396,13 +396,13 @@ the history stack. #### Returns -`Promise`<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> +`Promise`\<`undefined` \| `void` \| [`NavigationFailure`](NavigationFailure.md)\> ___ ### resolve -▸ **resolve**(`to`, `currentLocation?`): [`RouteLocation`](RouteLocation.md) & { `href`: `string` } +▸ **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 @@ -418,4 +418,4 @@ that includes any existing `base`. By default, the `currentLocation` used is #### Returns -[`RouteLocation`](RouteLocation.md) & { `href`: `string` } +[`RouteLocation`](RouteLocation.md) & \{ `href`: `string` } diff --git a/packages/docs/api/interfaces/RouterHistory.md b/packages/docs/api/interfaces/RouterHistory.md index 6f9e24845..a7fb4b017 100644 --- a/packages/docs/api/interfaces/RouterHistory.md +++ b/packages/docs/api/interfaces/RouterHistory.md @@ -153,7 +153,7 @@ ___ ▸ **replace**(`to`, `data?`): `void` -Same as [push](RouterHistory.md#push) but performs a `history.replaceState` +Same as [RouterHistory.push](RouterHistory.md#push) but performs a `history.replaceState` instead of `history.pushState` #### Parameters diff --git a/packages/docs/api/interfaces/RouterOptions.md b/packages/docs/api/interfaces/RouterOptions.md index 43548e2c6..039498275 100644 --- a/packages/docs/api/interfaces/RouterOptions.md +++ b/packages/docs/api/interfaces/RouterOptions.md @@ -80,7 +80,7 @@ ___ ▸ (`search`): [`LocationQuery`](../index.md#LocationQuery) Custom implementation to parse a query. See its counterpart, -[stringifyQuery](RouterOptions.md#stringifyQuery). +[RouterOptions.stringifyQuery](RouterOptions.md#stringifyQuery). ##### Parameters diff --git a/packages/docs/api/interfaces/RouterScrollBehavior.md b/packages/docs/api/interfaces/RouterScrollBehavior.md index b85e07775..049a72503 100644 --- a/packages/docs/api/interfaces/RouterScrollBehavior.md +++ b/packages/docs/api/interfaces/RouterScrollBehavior.md @@ -12,7 +12,7 @@ Type of the `scrollBehavior` option that can be passed to `createRouter`. ### RouterScrollBehavior -▸ **RouterScrollBehavior**(`to`, `from`, `savedPosition`): `Awaitable`<``false`` \| `void` \| `ScrollPosition`\> +▸ **RouterScrollBehavior**(`to`, `from`, `savedPosition`): `Awaitable`\<``false`` \| `void` \| `ScrollPosition`\> #### Parameters @@ -24,4 +24,4 @@ Type of the `scrollBehavior` option that can be passed to `createRouter`. #### Returns -`Awaitable`<``false`` \| `void` \| `ScrollPosition`\> +`Awaitable`\<``false`` \| `void` \| `ScrollPosition`\> diff --git a/packages/docs/guide/advanced/dynamic-routing.md b/packages/docs/guide/advanced/dynamic-routing.md index 17fab1eae..a2ad81a79 100644 --- a/packages/docs/guide/advanced/dynamic-routing.md +++ b/packages/docs/guide/advanced/dynamic-routing.md @@ -5,9 +5,9 @@ title="Learn how to add routes at runtime" /> -Adding routes to your router is usually done via the [`routes` option](../../api/#routes) but in some situations, you might want to add or remove routes while the application is already running. Application with extensible interfaces like [Vue CLI UI](https://cli.vuejs.org/dev-guide/ui-api.html) can use this to make the application grow. +Adding routes to your router is usually done via the `routes` option but in some situations, you might want to add or remove routes while the application is already running. Application with extensible interfaces like [Vue CLI UI](https://cli.vuejs.org/dev-guide/ui-api.html) can use this to make the application grow. -## Adding Routes +## Adding routes Dynamic routing is achieved mainly via two functions: `router.addRoute()` and `router.removeRoute()`. They **only** register a new route, meaning that if the newly added route matches the current location, it would require you to **manually navigate** with `router.push()` or `router.replace()` to display that new route. Let's take a look at an example: @@ -36,7 +36,7 @@ router.replace(router.currentRoute.value.fullPath) Remember you can `await router.replace()` if you need to wait for the new route to be displayed. -## Adding Routes inside navigation guards +## Adding routes inside navigation guards If you decide to add or remove routes inside of a navigation guard, you should not call `router.replace()` but trigger a redirection by returning the new location: @@ -111,5 +111,5 @@ router.addRoute({ Vue Router gives you two functions to look at existing routes: -- [`router.hasRoute()`](/api/interfaces/Router.md#Methods-hasRoute): check if a route exists -- [`router.getRoutes()`](/api/interfaces/Router.md#Methods-getRoutes): get an array with all the route records. +- [`router.hasRoute()`](/api/interfaces/Router.md#hasRoute): check if a route exists +- [`router.getRoutes()`](/api/interfaces/Router.md#getRoutes): get an array with all the route records. diff --git a/packages/docs/guide/advanced/navigation-failures.md b/packages/docs/guide/advanced/navigation-failures.md index cc76a38da..139197a7a 100644 --- a/packages/docs/guide/advanced/navigation-failures.md +++ b/packages/docs/guide/advanced/navigation-failures.md @@ -64,7 +64,7 @@ If you omit the second parameter: `isNavigationFailure(failure)`, it will only c ## Global navigation failures -You can detect global navigation failures globally by using the [`router.afterEach()` navigation guard](./navigation-guards.md#global-after-hooks): +You can detect global navigation failures globally by using the [`router.afterEach()` navigation guard](./navigation-guards.md#Global-After-Hooks): ```ts router.afterEach((to, from, failure) => { diff --git a/packages/docs/guide/advanced/navigation-guards.md b/packages/docs/guide/advanced/navigation-guards.md index 65c2532f0..fbad80c3a 100644 --- a/packages/docs/guide/advanced/navigation-guards.md +++ b/packages/docs/guide/advanced/navigation-guards.md @@ -25,13 +25,13 @@ Global before guards are called in creation order, whenever a navigation is trig Every guard function receives two arguments: -- **`to`**: the target route location [in a normalized format](../../api/#routelocationnormalized) being navigated to. -- **`from`**: the current route location [in a normalized format](../../api/#routelocationnormalized) being navigated away from. +- **`to`**: the target route location [in a normalized format](../../api/interfaces/RouteLocationNormalized.md) being navigated to. +- **`from`**: the current route location [in a normalized format](../../api/interfaces/RouteLocationNormalized.md) being navigated away from. And can optionally return any of the following values: - `false`: cancel the current navigation. If the browser URL was changed (either manually by the user or via back button), it will be reset to that of the `from` route. -- A [Route Location](../../api/#routelocationraw): Redirect to a different location by passing a route location as if you were calling [`router.push()`](../../api/#push), which allows you to pass options like `replace: true` or `name: 'home'`. The current navigation is dropped and a new one is created with the same `from`. +- A [Route Location](../../api/#RouteLocationRaw): Redirect to a different location by passing a route location as if you were calling `router.push()`, which allows you to pass options like `replace: true` or `name: 'home'`. The current navigation is dropped and a new one is created with the same `from`. ```js router.beforeEach(async (to, from) => { @@ -47,7 +47,7 @@ And can optionally return any of the following values: }) ``` -It's also possible to throw an `Error` if an unexpected situation was met. This will also cancel the navigation and call any callback registered via [`router.onError()`](../../api/#onerror). +It's also possible to throw an `Error` if an unexpected situation was met. This will also cancel the navigation and call any callback registered via [`router.onError()`](../../api/interfaces/Router.md#onError). If nothing, `undefined` or `true` is returned, **the navigation is validated**, and the next navigation guard is called. @@ -197,7 +197,7 @@ const routes = [ ] ``` -Note it is possible to achieve a similar behavior by using [route meta fields](./meta.md) and [global navigation guards](#global-before-guards). +Note it is possible to achieve a similar behavior by using [route meta fields](./meta.md) and global navigation guards. ## In-Component Guards diff --git a/packages/docs/guide/advanced/transitions.md b/packages/docs/guide/advanced/transitions.md index cc3fe6c97..f49c5ae9e 100644 --- a/packages/docs/guide/advanced/transitions.md +++ b/packages/docs/guide/advanced/transitions.md @@ -58,7 +58,7 @@ It is also possible to determine the transition to use dynamically based on the ``` -We can add an [after navigation hook](./navigation-guards.md#global-after-hooks) to dynamically add information to the `meta` field based on the depth of the route +We can add an [after navigation hook](./navigation-guards.md#Global-After-Hooks) to dynamically add information to the `meta` field based on the depth of the route ```js router.afterEach((to, from) => { diff --git a/packages/docs/guide/essentials/dynamic-matching.md b/packages/docs/guide/essentials/dynamic-matching.md index 61c730a3d..f74ab649d 100644 --- a/packages/docs/guide/essentials/dynamic-matching.md +++ b/packages/docs/guide/essentials/dynamic-matching.md @@ -36,7 +36,7 @@ You can have multiple _params_ in the same route, and they will map to correspon | /users/:username | /users/eduardo | `{ username: 'eduardo' }` | | /users/:username/posts/:postId | /users/eduardo/posts/123 | `{ username: 'eduardo', postId: '123' }` | -In addition to `$route.params`, the `$route` object also exposes other useful information such as `$route.query` (if there is a query in the URL), `$route.hash`, etc. You can check out the full details in the [API Reference](../../api/#routelocationnormalized). +In addition to `$route.params`, the `$route` object also exposes other useful information such as `$route.query` (if there is a query in the URL), `$route.hash`, etc. You can check out the full details in the [API Reference](../../api/interfaces/RouteLocationNormalized.md). A working demo of this example can be found [here](https://codesandbox.io/s/route-params-vue-router-examples-mlb14?from-embed&initialpath=%2Fusers%2Feduardo%2Fposts%2F1). @@ -116,7 +116,7 @@ this.$router.push({ }) ``` -See more in the [repeated params](./route-matching-syntax.md#repeatable-params) section. +See more in the [repeated params](./route-matching-syntax.md#Repeatable-params) section. If you are using [History mode](./history-mode.md), make sure to follow the instructions to correctly configure your server as well. diff --git a/packages/docs/guide/essentials/history-mode.md b/packages/docs/guide/essentials/history-mode.md index bdcdc5d45..11e9e9994 100644 --- a/packages/docs/guide/essentials/history-mode.md +++ b/packages/docs/guide/essentials/history-mode.md @@ -64,7 +64,7 @@ While it's not recommended, you can use this mode inside Browser applications bu ## Example Server Configurations -**Note**: The following examples assume you are serving your app from the root folder. If you deploy to a subfolder, you should use [the `publicPath` option of Vue CLI](https://cli.vuejs.org/config/#publicpath) and the related [`base` property of the router](../../api/#Functions-createWebHistory). You also need to adjust the examples below to use the subfolder instead of the root folder (e.g. replacing `RewriteBase /` with `RewriteBase /name-of-your-subfolder/`). +**Note**: The following examples assume you are serving your app from the root folder. If you deploy to a subfolder, you should use [the `publicPath` option of Vue CLI](https://cli.vuejs.org/config/#publicpath) and the related [`base` property of the router](../../api/interfaces/Router.md#createWebHistory). You also need to adjust the examples below to use the subfolder instead of the root folder (e.g. replacing `RewriteBase /` with `RewriteBase /name-of-your-subfolder/`). ### Apache diff --git a/packages/docs/guide/essentials/named-routes.md b/packages/docs/guide/essentials/named-routes.md index 883c5dd77..eb43626e0 100644 --- a/packages/docs/guide/essentials/named-routes.md +++ b/packages/docs/guide/essentials/named-routes.md @@ -40,4 +40,4 @@ In both cases, the router will navigate to the path `/user/erina`. Full example [here](https://github.com/vuejs/vue-router/blob/dev/examples/named-routes/app.js). -Each name **must be unique** across all routes. If you add the same name to multiple routes, the router will only keep the last one. You can read more about this [in the Dynamic Routing](../advanced/dynamic-routing.md#removing-routes) section. +Each name **must be unique** across all routes. If you add the same name to multiple routes, the router will only keep the last one. You can read more about this [in the Dynamic Routing](../advanced/dynamic-routing.md#Removing-routes) section. diff --git a/packages/docs/guide/essentials/navigation.md b/packages/docs/guide/essentials/navigation.md index acb7fa36c..602ebb6f7 100644 --- a/packages/docs/guide/essentials/navigation.md +++ b/packages/docs/guide/essentials/navigation.md @@ -56,7 +56,7 @@ router.push({ name: 'user', params: { username } }) // -> /user/eduardo router.push({ path: '/user', params: { username } }) // -> /user ``` -When specifying `params`, make sure to either provide a `string` or `number` (or an array of these for [repeatable params](./route-matching-syntax.md#repeatable-params)). **Any other type (like objects, booleans, etc) will be automatically stringified**. For [optional params](./route-matching-syntax.md#optional-parameters), you can provide an empty string (`""`) or `null` as the value to remove it. +When specifying `params`, make sure to either provide a `string` or `number` (or an array of these for [repeatable params](./route-matching-syntax.md#Repeatable-params)). **Any other type (like objects, booleans, etc) will be automatically stringified**. For [optional params](./route-matching-syntax.md#Optional-parameters), you can provide an empty string (`""`) or `null` as the value to remove it. Since the prop `to` accepts the same kind of object as `router.push`, the exact same rules apply to both of them. @@ -110,4 +110,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](../../api/#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 `history` option passed when creating the router instance. diff --git a/packages/docs/guide/index.md b/packages/docs/guide/index.md index 6003571ce..2d826e71e 100644 --- a/packages/docs/guide/index.md +++ b/packages/docs/guide/index.md @@ -1,9 +1,8 @@ # Getting Started Watch a Free Vue Router Video Course +href="https://vueschool.io/courses/vue-router-4-for-everyone" +title="Learn how to build powerful Single Page Applications with the Vue Router on Vue School">Watch a Free Vue Router Video Course Creating a Single-page Application with Vue + Vue Router feels natural: with Vue.js, we are already composing our application with components. When adding Vue Router to the mix, all we need to do is map our components to the routes and let Vue Router know where to render them. Here's a basic example: @@ -97,6 +96,6 @@ export default { } ``` -To access the router or the route inside the `setup` function, call the `useRouter` or `useRoute` functions. We will learn more about this in [the Composition API](./advanced/composition-api.md#accessing-the-router-and-current-route-inside-setup) +To access the router or the route inside the `setup` function, call the `useRouter` or `useRoute` functions. We will learn more about this in [the Composition API](./advanced/composition-api.md#Accessing-the-Router-and-current-Route-inside-setup) Throughout the docs, we will often use the `router` instance. Keep in mind that `this.$router` is exactly the same as directly using the `router` instance created through `createRouter`. The reason we use `this.$router` is because we don't want to import the router in every single component that needs to manipulate routing. diff --git a/packages/docs/guide/migration/index.md b/packages/docs/guide/migration/index.md index f806bf4c5..c4bcbd624 100644 --- a/packages/docs/guide/migration/index.md +++ b/packages/docs/guide/migration/index.md @@ -210,7 +210,7 @@ The `exact` prop has been removed because the caveat it was fixing is no longer - Routes are now active based on the route records they represent instead of the generated route location objects and their `path`, `query`, and `hash` properties - Only the `path` section is matched, `query`, and `hash` aren't taken into account anymore -If you wish to customize this behavior, e.g. take into account the `hash` section, you should use the [`v-slot` API](/guide/advanced/composition-api#uselink) to extend ``. +If you wish to customize this behavior, e.g. take into account the `hash` section, you should use the [`v-slot` API](/guide/advanced/composition-api#useLink) to extend ``. **Reason**: See the [RFC about active matching](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0028-router-active-link.md#summary) changes for more details. @@ -220,7 +220,7 @@ At the moment navigation guards in mixins are not supported. You can track its s ### Removal of `router.match` and changes to `router.resolve` -Both `router.match`, and `router.resolve` have been merged together into `router.resolve` with a slightly different signature. [Refer to the API](/api/interfaces/Router.md#Methods-resolve) for more details. +Both `router.match`, and `router.resolve` have been merged together into `router.resolve` with a slightly different signature. [Refer to the API](/api/interfaces/Router.md#resolve) for more details. **Reason**: Uniting multiple methods that were used for the same purpose. @@ -437,7 +437,7 @@ Decoded values in `params`, `query`, and `hash` are now consistent no matter whe Given any [normalized route location](/api/interfaces/RouteLocationNormalized.md): - Values in `path`, `fullPath` are not decoded anymore. They will appear as provided by the browser (most browsers provide them encoded). e.g. directly writing on the address bar `https://example.com/hello world` will yield the encoded version: `https://example.com/hello%20world` and both `path` and `fullPath` will be `/hello%20world`. -- `hash` is now decoded, that way it can be copied over: `router.push({ hash: $route.hash })` and be used directly in [scrollBehavior](/api/interfaces/RouterOptions.md#Properties-scrollBehavior)'s `el` option. +- `hash` is now decoded, that way it can be copied over: `router.push({ hash: $route.hash })` and be used directly in [scrollBehavior](/api/interfaces/RouterOptions.mdscrollBehavior)'s `el` option. - When using `push`, `resolve`, and `replace` and providing a `string` location or a `path` property in an object, **it must be encoded** (like in the previous version). On the other hand, `params`, `query` and `hash` must be provided in its unencoded version. - The slash character (`/`) is now properly decoded inside `params` while still producing an encoded version on the URL: `%2F`. diff --git a/packages/docs/package.json b/packages/docs/package.json index 940f7f641..c2392f1c9 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "docs": "vitepress dev .", - "docs:api": "node run-typedoc.js", + "docs:api": "node run-typedoc.mjs", "docs:build": "vitepress build ." }, "dependencies": {