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
Copy file name to clipboardExpand all lines: docs/guide/advanced/navigation-failures.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,16 @@
2
2
3
3
> New in 3.4.0
4
4
5
-
When using `router-link`, Vue Router internally calls `router.push` to trigger a navigation. Depending on the current location and existing [Navigation Guards](./navigation-guards.md), this navigation might end up in a new page being shown, but there are a couple of situations where we will stay on the same page:
5
+
When using `router-link`, Vue Router calls `router.push` to trigger a navigation. While the expected behavior for most links is to navigate a user to a new page, there are a few situations where users will remain on the same page:
6
6
7
7
- We are already on the page we are trying to go to
8
-
- A navigation guard aborts the navigation by calling `next(false)`
9
-
- A navigation guard throws an error or calls `next(new Error())`
8
+
- A [navigation guard](./navigation-guards.md) aborts the navigation by calling `next(false)`
9
+
- A [navigation guard](./navigation-guards.md) throws an error or calls `next(new Error())`
10
10
11
11
When using a regular `router-link`, **none of these failures will log an error**. However, if you are using `router.push` or `router.replace`, you might come across an _"Uncaught (in promise) Error"_ message followed by a more specific message in your console. Let's understand how to differentiate _Navigation Failures_.
12
12
13
13
::: tip Background story
14
-
_Navigation Failures_ were exposed on version 3.2.0 but existed for a long time before: through the two optional callbacks of `router.push`,`onComplete` and `onAbort` that can be passed to `router.push`. Since version 3.1.0, `router.push` and `router.replace` return a _Promise_ if no `onComplete`/`onAbort` callback is provided. This _Promise_ resolves instead of invoking `onComplete` and rejects instead of invoking `onAbort`.
14
+
In v3.2.0, _Navigation Failures_ were exposed through the two optional callbacks of `router.push`:`onComplete` and `onAbort`. Since version 3.1.0, `router.push` and `router.replace` return a _Promise_ if no `onComplete`/`onAbort` callback is provided. This _Promise_ resolves instead of invoking `onComplete` and rejects instead of invoking `onAbort`.
15
15
:::
16
16
17
17
## Detecting Navigation Failures
@@ -36,7 +36,7 @@ If you omit the second parameter: `isNavigationFailure(failure)`, it will only c
36
36
37
37
## `NavigationFailureType`
38
38
39
-
`NavigationFailureType`exposes the following properties to differentiate _Navigation Failures_:
39
+
`NavigationFailureType`help developers to differentiate between the various types of _Navigation Failures_. There are four different types:
40
40
41
41
-`redirected`: `next(newLocation)` was called inside of a navigation guard to redirect somewhere else.
42
42
-`aborted`: `next(false)` was called inside of a navigation guard to the navigation.
0 commit comments