向后导航时如何跳过浏览器历史记录中的页面? [英] How to skip a page in browser history when navigating back?

查看:115
本文介绍了向后导航时如何跳过浏览器历史记录中的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在路由器上有一个Angular 2应用程序.假设用户在应用程序的页面A上,然后他导航到页面B,然后导航到页面C.这时,当他单击浏览器上的后退"按钮时,我希望他返回页面A(跳过B).我该如何实现?

I have an Angular 2 app with the Router. Let's say the user is on a page A in the app, he then navigates to a page B and then to a page C. At this moment when he clicks the Back button on the browser I want him to get back to the page A (by skipping B). How can I achieve it?

推荐答案

从B导航到C时,必须设置{replaceUrl:true}:

When navigating from B to C one has to set { replaceUrl: true }:

this.router.navigate(["/c"], { replaceUrl: true });

这会将浏览器历史记录中的页面B替换为C.

This replaces the page B by C in the browser history.

这篇关于向后导航时如何跳过浏览器历史记录中的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆