vue-router路由跳转到其他地址,如何不保留历史记录

页面路由配置了两个

{
  path: 'index',
  name: 'introduce',
  component: page.introduce,
},
{
  path: 'detail',
  name: 'detail',
  component: page.detail,
}

由先由index跳转到detail, detail再跳转其他地址如百度或者什么的,再点击微信端的返回,如何直接返回到第一个页面?

阅读 13.5k
3 个回答

this.$router.replace()

跳到百度之后就不归你管了.
可以在你的路由或者组件里面判断document.referrer是不是为其他网址.是的话返回第一个页面.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题