const router = new VueRouter({
routes,
});
router.beforeEach((to, from, next) => {
if (to.path == "/login") {
next();
} else {
var status = sessionStorage.getItem("logon");
if (status) {
next();
} else {
alert("请登录");
next("/login");
}
}
});
这个是路由防止跳转,代码仅供参考