router.js:
import Vue from 'vue' import Router from 'vue-router' import store from '@/store' Vue.use(Router) /* Layout */ import Layout from '@/layout' import Login from '@/views/login/index' export const asyncRoutes = [ { path: '/', component: Layout, redirect: to=>{ console.log('重定向了') console.log(store.state.user) if(store.state.user.name=='editor2'){ //评论管理 return '/discuss/index' }else if(store.state.user.name=='editor'){ //用户权限管理 return '/tree/index' }else{ //内容用户权限管理 return '/dashboard' } }, children: [{ path: 'dashboard', name: 'Dashboard', component: () => import('@/views/dashboard/index'), meta: { title: '内容发布管理', icon: 'dashboard' } }] }, ]