われわれが知っているように、同じコンポーネントのparams変更に反応するには、beforeRouteUpdate
フックまたは$route
を使用します。 $ルートを見て
:
const User = {
template: '...',
watch: {
'$route' (to, from) {
// react to route changes...
}
}
}
beforeRouteUpdate方法:
const User = {
template: '...',
beforeRouteUpdate (to, from, next) {
// react to route changes...
next()
}
}
これら2つの違いは何ですか?両方が同じ場合、なぜvue routerがbeforeRouteUpdate
を導入したのですか? beforeRouteUpdate
上documentationから