有时候开发需要获取当前url的参数
完整url可以用
window.location.href
路由路径可以用
this.$route.path
路由路径参数
this.$route.params
(params是参数名称)
也可以直接watch监听一下当前路由的信息
watch:{
$route(to, from) {
console.log(window.location.href);
console.log(this.$route.path);
console.log(this.$route.params);
}
}