用路由守卫 router.beforeEach((to, from, next) => { if (to.path !== '/web/login') { // 检查登录状态 axios.post('checked/login').then(response => { let data = response.data; if (data.info.status === 4) { next('/web/index'); } else { next(); } }); } else { next(); } }); 检查当前路由: mounted() { if (this.$route.path !== '/web/index') { // 请求检查登录接口 axios.post('checked/login').then(response => { let data = response.data; if (data.info.status === 4) { this.$router.push('/web/index'); } }); } }