獲取當前頁面路由
- 完整url可以用 window.location.href
- 路由路徑可以用 this.$route.path
- 路由路徑參數 this.$route.params
判斷當前路由不匹配時跳轉
if(this.$route.path!='/Home'){ this.$router.push({ path:'/Home', }) }
vue $router和$route的區別
route相當於當前正在跳轉的路由對象 可以從里面獲取name,path,params,query等
打印this.$route和this.$router

轉載https://blog.csdn.net/yangwqi/article/details/107916506
