P粉5292450502023-08-26 11:39:41
const routes = [ { path: '/login', name: 'Login', component: () => import('../views/login'), meta: { requiresAuth: false } }, { path: '/private', ... private route config, meta: { requiresAuth: true } } ]; router.beforeEach(async (to, from, next) => { if (ENV == 'development') { if (to.matched.some(record => record.meta.requiresAuth)) { const sessionStorage = storage.sessionStorageGet('_sessionToken') if (sessionStorage) { next(); } else { router.push({ name: 'Login' }); } } else { next(); } } });