vue 检查登录的接口,在页面登录跳转后会再次请求 造成了死循环?-灵析社区

谁能阻止我删代码

用路由守卫 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'); } }); } }

阅读量:1

点赞量:0

问AI