first commit
This commit is contained in:
27
src/router/index.js
Normal file
27
src/router/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import Router from "vue-router"
|
||||
import store from "@/store/index.js"
|
||||
let router = new Router({
|
||||
routes:[
|
||||
{
|
||||
path:"/",
|
||||
component:() => import("../views/index.vue")
|
||||
},
|
||||
{
|
||||
path:"/login",
|
||||
component:() => import("@/views/login.vue")
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
console.log(to.path,store.state.quanxian)
|
||||
if(store.state.quanxian){
|
||||
next()
|
||||
}else if(to.path != "/login"){
|
||||
router.push("/login")
|
||||
}else{
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user