您的位置:首页技术文章
文章详情页

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

【字号: 日期:2022-12-15 10:14:22浏览:58作者:猪猪

问题描述

页面路由配置了两个

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

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

问题解答

回答1:

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

回答2:

window.location.replace()

回答3:

this.$router.replace()

标签: JavaScript