您现在的位置是:网站首页> 编程资料编程资料
vue跳转后不记录历史记录的问题_vue.js_
2023-05-24
283人已围观
简介 vue跳转后不记录历史记录的问题_vue.js_
vue跳转后不记录历史记录
vue路由跳转一般情况下是使用push,
this.$router.push({ path: "/testTeam/testTeam", });若是特殊需求,页面跳转后不记录到历史记录中,将push改为replace即可
this.$router.replace({path: '/project_selection'})vue-router回退不记录历史
场景说明
对于单页应用来说,经常会有登录后访问某个页面的场景。比如
/index -> /login -> /page1
但是在page1返回上一页时,会返回到登录页。回退路径为
/page1-> /login -> /index
因此需要进行跳过登录页的历史记录处理。
处理方案
1.router-link + history
login页登录后访问page1
此时在page1页的回退路径为
/page1 -> /index
2.编程式跳转
login页
结果同上。
其他api跳转
此外,router对象还有其他跳转api使用说明如下
/** * Go back in history if possible by calling `history.back()`. Equivalent to * `router.go(-1)`. */ back(): ReturnType; /** * Go forward in history if possible by calling `history.forward()`. * Equivalent to `router.go(1)`. */ forward(): ReturnType ; /** * Allows you to move forward or backward through the history. Calls * `history.go()`. * * @param delta - The position in the history to which you want to move, * relative to the current page */ go(delta: number): void;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。
您可能感兴趣的文章:
相关内容
- 开启Vue项目缺少node_models包的问题及解决_vue.js_
- 微信小程序引入外部icon(阿里巴巴矢量图标)的全过程_javascript技巧_
- Vue 中指令v-bind动态绑定及与v-for结合使用详解_vue.js_
- 微信小程序实现tabbar凹凸圆选中动画效果实例_javascript技巧_
- vue3中使用ref语法糖的示例代码_vue.js_
- react Suspense工作原理解析_React_
- react项目中@路径简单配置指南_React_
- 使用Vue3实现羊了个羊的算法_vue.js_
- vue中的axios配置及接口请求路径api配置_vue.js_
- 在Vue使用$attrs实现构建高级组件_vue.js_
