import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const login = () => import('../pages/login/login')
export const router=new Router({
routes:[
{
path:"/login",
component:login
},
{
path:"/index",
component:index,
children:[
二级路由
{
path:'',
redirect:'home' 重定向组件要加 ‘ ’
},
{
path:'xx', 二级路由地址不需要加/
component:cart
}
]
}
]
})
全局守卫
router.beforeEach((to,form,next)=>{
if(to.path==='/login'){
next()
return
}
if(userInfo.username){
next()
return
}
next('/login')
})
路由index
最新推荐文章于 2024-04-16 14:30:17 发布