Skip to content

Commit 9b7f766

Browse files
committed
update docs for 2.4
1 parent 4e3b377 commit 9b7f766

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

docs/en/advanced/navigation-guards.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Every guard function receives three arguments:
3232

3333
- **`next('/')` or `next({ path: '/' })`**: redirect to a different location. The current navigation will be aborted and a new one will be started.
3434

35+
- **`next(error)`**: (2.4.0+) if the argument passed to `next` is an instance of `Error`, the navigation will be aborted and the error will be passed to callbacks registered via `router.onError()`.
36+
3537
**Make sure to always call the `next` function, otherwise the hook will never be resolved.**
3638

3739
You can also register global after hooks, however unlike guards, these hooks do not get a `next` function and cannot affect the navigation:

docs/en/api/options.md

+8
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@
6868
```
6969

7070
For more details see [Scroll Behavior](../advanced/scroll-behavior.md).
71+
72+
### parseQuery / stringifyQuery
73+
74+
> 2.4.0+
75+
76+
- type: `Function`
77+
78+
Provide custom query string parse / stringify functions. Overrides the default.

docs/en/api/router-instance.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,24 @@
6060
6161
Dynamically add more routes to the router. The argument must be an Array using the same route config format with the `routes` constructor option.
6262

63-
- **router.onReady(callback)**
63+
- **router.onReady(callback, [errorCallback])**
6464

6565
> 2.2.0+
6666
6767
This method queues a callback to be called 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.
6868

6969
This is useful in server-side rendering to ensure consistent output on both the server and the client.
70+
71+
The second argument `errorCallback` is only supported in 2.4+. It will be called when the initial route resolution runs into an error (e.g. failed to resolve an async component).
72+
73+
- **router.onError(callback)**
74+
75+
> 2.4.0+
76+
77+
Register a callback which will be called when an error is caught during a route navigation. Note for an error to be called, it must be one of the following scenarios:
78+
79+
- The error is thrown synchronously inside a route guard function;
80+
81+
- The error is caught and asynchronously handled by calling `next(err)` inside a route guard function;
82+
83+
- An error occurred when trying to resolve an async component that is required to render a route.

0 commit comments

Comments
 (0)