Skip to content

Commit fcf5e73

Browse files
committed
Update docs for beforeRouteUpdate next callback
1 parent 7afedcb commit fcf5e73

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/en/advanced/navigation-guards.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,19 @@ beforeRouteEnter (to, from, next) {
116116
}
117117
```
118118

119-
Note that `beforeRouteEnter` is the only guard that supports passing a callback to `next`. For `beforeRouteUpdate` and `beforeRouteLeave`, `this` is already available, so passing a callback is unnecessary and therefore *not supported*:
120-
121119
```js
122120
beforeRouteUpdate (to, from, next) {
123-
// just use `this`
121+
// may use `this`
124122
this.name = to.params.name
125-
next()
123+
124+
// may also pass a callback to next
125+
next(vm => {
126+
vm.name = to.params.name
127+
})
126128
}
127129
```
128130

129-
The **leave guard** is usually used to prevent the user from accidentally leaving the route with unsaved edits. The navigation can be canceled by calling `next(false)`.
131+
The **leave guard** is usually used to prevent the user from accidentally leaving the route with unsaved edits. The navigation can be canceled by calling `next(false)`. Note that `beforeRouteLeave` is the only guard that does not support passing a callback to `next`.
130132

131133
```js
132134
beforeRouteLeave (to, from , next) {

0 commit comments

Comments
 (0)