main.js:
router.beforeEach((to, from, next) => { const loginPath = '/login' if (to.path !== loginPath && !localStorage.getItem('user')) { next(loginPath) } else { next() } })
main.js:
router.beforeEach((to, from, next) => { const loginPath = '/login' if (to.path !== loginPath && !localStorage.getItem('user')) { next(loginPath) } else { next() } })