vue中的route


1. 当前的页面路径

if(this.$route.path==='/todo'){
//代码
return;
}else{
this.$router.push("todo");
}  

注:this.$router代表当前的路由对象。

       this.$route代表着一类路由,调用方法时。

2.$route.matched

    匹配所有的路由,主要用于动态路由配置,权限那里。

3. 路由n级

/ 表示根目录

/home 一级路由

/home/child 二级路由 

几级路由对应几几路由的 router-view,所以层级不能乱

参考自: https://www.zhangshengrong.com/p/AvN6Y5nWam/

vue