导航守卫
This commit is contained in:
parent
aacc01f72b
commit
b334f528cf
@ -18,6 +18,9 @@ export default {
|
||||
let zhi = this.$route.params;
|
||||
console.log(zhi);
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
console.log(this.$route,"组建内")
|
||||
}
|
||||
}
|
||||
</script>
|
@ -8,24 +8,43 @@ const router = new VueRouter({
|
||||
routes: [{
|
||||
path:"/index",
|
||||
component:index,
|
||||
meta:["user","admin"],
|
||||
children:[{
|
||||
path:"table",
|
||||
meta:["user","admin"],
|
||||
component: () => import("../pages/table.vue")
|
||||
},{
|
||||
path:"list",
|
||||
meta:["admin"],
|
||||
component: list
|
||||
}]
|
||||
},{
|
||||
path:"/list",
|
||||
name:"list",
|
||||
component:list
|
||||
component:list,
|
||||
meta:["admin"],
|
||||
},{
|
||||
path:"/login",
|
||||
meta:["user","admin"],
|
||||
component: ()=> import("../pages/login.vue")
|
||||
},{
|
||||
path:"*",
|
||||
meta:["user","admin"],
|
||||
component: ()=> import("../pages/404.vue")
|
||||
}]
|
||||
})
|
||||
|
||||
// const shenfen = "admin" user
|
||||
// 0
|
||||
// 1
|
||||
// 登录状态 本地有没有登录的信息
|
||||
const shenfen = "user"
|
||||
router.beforeEach((to,form,next)=>{
|
||||
console.log(to)
|
||||
if(to.meta.includes(shenfen)){
|
||||
next()
|
||||
}else{
|
||||
next("/login")
|
||||
}
|
||||
// 路由源信息
|
||||
})
|
||||
export default router
|
Loading…
Reference in New Issue
Block a user