You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -54,7 +54,7 @@ Setting `replace` prop will call `router.replace()` instead of `router.push()` w
54
54
### active-class
55
55
56
56
- type: `string`
57
-
- default: `"router-link-active"` (or global [`routerLinkActiveClass`](#TODO))
57
+
- default: `"router-link-active"` (or global [`linkActiveClass`](#linkactiveclass))
58
58
59
59
Class to apply on the rendered `a` when the link is active.
60
60
@@ -81,15 +81,17 @@ Whether `<router-link>` should not wrap its content in an `<a>` element. Useful
81
81
### exact-active-class
82
82
83
83
- type: `string`
84
-
- default: `"router-link-exact-active"` (or global [`routerLinkExactActiveClass`](#TODO))
84
+
- default: `"router-link-exact-active"` (or global [`linkExactActiveClass`](#linkexactactiveclass))
85
85
86
86
Class to apply when the link is exact active.
87
87
88
88
## `<router-link>`'s `v-slot`
89
89
90
90
`<router-link>` exposes a low level customization through a [scoped slot](https://v3.vuejs.org/guide/component-slots.html#scoped-slots). This is a more advanced API that primarily targets library authors but can come in handy for developers as well, to build a custom component like a _NavLink_ or other.
91
91
92
-
\*\*Remember to pass the `custom` option to `<router-link>` to prevent it from wrapping its content inside of an `<a>` element.
92
+
:::tip
93
+
Remember to pass the `custom` option to `<router-link>` to prevent it from wrapping its content inside of an `<a>` element.
94
+
:::
93
95
94
96
```html
95
97
<router-link
@@ -116,6 +118,7 @@ Sometimes we may want the active class to be applied to an outer element rather
@@ -145,7 +148,7 @@ When a `<router-view>` has a `name`, it will render the component with the corre
145
148
146
149
## createRouter
147
150
148
-
Creates a Router instance that can be used by a Vue app.
151
+
Creates a Router instance that can be used by a Vue app. Check the [RouterOptions](#routeroptions) for a list of all the properties that can be passed.
149
152
150
153
**Signature:**
151
154
@@ -155,9 +158,113 @@ export declare function createRouter(options: RouterOptions): Router
Historyimplementationusedbytherouter. Mostwebapplicationsshoulduse`createWebHistory`butitrequirestheservertobeproperlyconfigured. Youcanalsousea_hash_basedhistorywith`createWebHashHistory`thatdoesnotrequireanyconfigurationontheserverbutisn't handled at all by search engines and does poorly on SEO.
Let'ssayyouwanttousethepackage [qs](https://github.com/ljharb/qs) to parse queries, you can provide both `parseQuery` and `stringifyQuery`:
219
+
220
+
```js
221
+
importqsfrom 'qs'
222
+
223
+
createRouter({
224
+
// other options...
225
+
parse:qs.parse,
226
+
stringifyQuery:qs.stringify,
227
+
})
228
+
```
229
+
230
+
### routes
231
+
232
+
Initial list of routes that should be added to the router.
233
+
234
+
**Signature:**
235
+
236
+
```typescript
237
+
routes: RouteRecordRaw[];
238
+
```
239
+
240
+
### scrollBehavior
241
+
242
+
Function to control scrolling when navigating between pages. Can return a Promise to delay scrolling. Check .
243
+
244
+
**Signature:**
245
+
246
+
```typescript
247
+
scrollBehavior?:ScrollBehavior;
248
+
```
249
+
250
+
#### Examples
251
+
252
+
```js
253
+
functionscrollBehavior(to, from, savedPosition) {
254
+
// `to` and `from` are both route locations
255
+
// `savedPosition` can be null if there isn't one
256
+
}
257
+
```
258
+
259
+
### stringifyQuery
260
+
261
+
Custom implementation to stringify a query object. Should not prepend a leading `?`. [parseQuery](#parsequery) counterpart to handle query parsing.
262
+
263
+
**Signature:**
264
+
265
+
```typescript
266
+
stringifyQuery?:typeoforiginalStringifyQuery;
267
+
```
161
268
162
269
## createWebHistory
163
270
@@ -216,7 +323,7 @@ createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/in
216
323
217
324
## createMemoryHistory
218
325
219
-
Creates a in-memory based history. The main purpose of this history is to handle SSR. It starts in a special ___location that is nowhere. It's up to the user to replace that ___location with the starter ___location.
326
+
Creates a in-memory based history. The main purpose of this history is to handle SSR. It starts in a special ___location that is nowhere. It's up to the user to replace that ___location with the starter ___location by either calling `router.push` or `router.replace`.
220
327
221
328
**Signature:**
222
329
@@ -226,10 +333,78 @@ export declare function createMemoryHistory(base?: string): RouterHistory
Copy file name to clipboardExpand all lines: docs/api/vue-router-function.md
-32Lines changed: 0 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,38 +6,6 @@
6
6
7
7
## isNavigationFailure
8
8
9
-
## onBeforeRouteLeave
10
-
11
-
Add a navigation guard that triggers whenever the component for the current ___location is about to be left. Similar to but can be used in any component. The guard is removed when the component is unmounted.
Transforms a queryString into a [LocationQuery](./vue-router-typealias#locationquery) object. Accept both, a version with the leading `?` and without Should work as URLSearchParams
0 commit comments