//整个实例出来 配置路由守卫 const router = new Router({ //这里面是路由配置哈 }) router.beforeEach((to, from, next) => { if (to.path == "/login") { next(); } else { const token = localStorage.getItem("token"); if (token) { next(); } else { router.push({ name: "login" }); } } });