导航钩子
beforeRouterEnter afterEnter beforeRouterUpdate beforeRouterLeave
vue路由跳转=声明式 link to+编程式 push
vue路由传参=params+query
params又分为url中显示参数和不显示参数
编程式
0)不传参
定义 {path:‘/login‘.component......}
使用 this.$router.push({path:‘/login‘})
1)
定义 {path:‘/login/:id‘.component......}
使用 this.$router.push({path:`/login/${id}`})
获取 this.$route.params.id
2)
定义 {path:‘/login/:id‘,name=‘haha‘.......}
使用 push({name:‘haha‘,params:{id:id}})
获取 this.$route.params.id
3)url中会显示?id=
定义 {path:‘/login/:id‘,.......}
使用 push({path:‘/login‘,query:{id:id}})
获取 this.$route.query.id
声明式
1)url显示 params
定义 {path:‘/login/:id‘,.......}
使用 <router-link to=‘/login/01‘></>
获取 this.$route.params.id
2)url不显示
定义 {path:‘/login/:id‘,name=‘haha‘.......}
使用 <router-link to="{name:‘haha‘,params:{id:id}}"></>
获取 this.$route.params.id
3)
定义 {path:‘/login/:id‘,......}
使用 <router-link to="{name:‘haha‘,query:{id:id}}"></>
获取 this.$route.query.id
二级路由 children:[]
vue 路由
原文:https://www.cnblogs.com/mokani/p/10492190.html