路由相关
watch:{
$route(to,from){
console.log(to.path);
}
watch: {
$route: {
handler: function(val, oldVal){
console.log(val);
},
deep: true
}
},
watch: {
'$route':'getPath'
},
methods: {
getPath(){
console.log(this.$route.path);
}
}
beforeRouteEnter(to, from, next) {
console.log(this, 'beforeRouteEnter');
console.log(to, '组件独享守卫beforeRouteEnter第一个参数');
console.log(from, '组件独享守卫beforeRouteEnter第二个参数');
console.log(next, '组件独享守卫beforeRouteEnter第三个参数');
next(vm => {
console.log(vm);
});
},
beforeRouteUpdate(to, from, next) {
console.log(this, 'beforeRouteUpdate');
console.log(to, '组件独享守卫beforeRouteUpdate第一个参数');
console.log(from, '组件独享守beforeRouteUpdate卫第二个参数');
console.log(next, '组件独享守beforeRouteUpdate卫第三个参数');
next();
},
beforeRouteLeave(to, from, next) {
console.log(this, 'beforeRouteLeave');
console.log(to, '组件独享守卫beforeRouteLeave第一个参数');
console.log(from, '组件独享守卫beforeRouteLeave第二个参数');
console.log(next, '组件独享守卫beforeRouteLeave第三个参数');
next();
}