【发布时间】:2018-04-21 09:54:56
【问题描述】:
我们知道,要对同一组件中的参数更改做出反应,我们使用beforeRouteUpdate 挂钩或监视$route。
观看 $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()
}
}
这两者有什么区别?如果两者都一样,那为什么 vue 路由器要引入beforeRouteUpdate?
【问题讨论】:
标签: vue.js vuejs2 vue-router