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/en/advanced/navigation-guards.md
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,11 @@ These guards have the exact same signature as global before guards.
64
64
65
65
### In-Component Guards
66
66
67
-
Finally, you can directly define route navigation guards inside route components (the ones passed to the router configuration) with `beforeRouteEnter` and `beforeRouteLeave`:
67
+
Finally, you can directly define route navigation guards inside route components (the ones passed to the router configuration) with the following options:
68
+
69
+
-`beforeRouteEnter`
70
+
-`beforeRouteUpdate` (added in 2.2)
71
+
-`beforeRouteLeave`
68
72
69
73
```js
70
74
constFoo= {
@@ -74,6 +78,14 @@ const Foo = {
74
78
// does NOT have access to `this` component instance,
75
79
// because it has not been created yet when this guard is called!
76
80
},
81
+
beforeRouteUpdate (to, from, next) {
82
+
// called when the route that renders this component has changed,
83
+
// but this component is reused in the new route.
84
+
// For example, for a route with dynamic params /foo/:id, when we
85
+
// navigate between /foo/1 and /foo/2, the same Foo component instance
86
+
// will be reused, and this hook will be called when that happens.
87
+
// has access to `this` component instance.
88
+
},
77
89
beforeRouteLeave (to, from, next) {
78
90
// called when the route that renders this component is about to
0 commit comments