From b334f528cf6a59fc28e292c42c503cf5016e2124 Mon Sep 17 00:00:00 2001 From: theluyuan <1162963624@qq.com> Date: Wed, 1 Sep 2021 09:43:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/list.vue | 3 +++ src/router/index.js | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) 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