企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 需求 **用户在登陆后返回之前浏览的页面** ### 解决方案 #### 在拦截器或者路由首位中跳转携带参数,本次案例采用路由守卫的方式 ``` // 引入路由 import router from '../../router/index' // 跳转 beforeRouteEnter: (to, from, next) => { if (Storage.sessionGet('token')) { next() } else { next({ path: '/login', query: {redirect: router.currentRoute.fullPath}//登录成功后跳入浏览的当前页面) }) } } ``` #### 登陆成功后进行页面的跳转 ``` if(that.$router.query && that.$router.query.redirect) { that.$router.push({path:decodeURIComponent(that.$router.query.redirect)}) }else { that.$router.go(-1) } ```