diff --git a/src/pages/list.vue b/src/pages/list.vue index bc8fe63..1c5f4e0 100644 --- a/src/pages/list.vue +++ b/src/pages/list.vue @@ -18,6 +18,9 @@ export default { let zhi = this.$route.params; console.log(zhi); } + }, + mounted(){ + console.log(this.$route,"组建内") } } \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index c20ef8c..65460d4 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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 \ No newline at end of file