我现在需要你的帮助!
我有Angular Router,我想导航到另一个url而不将其添加到浏览器历史记录中,因为后退按钮会一次又一次地将用户返回到url。
this.router.navigateByUrl(`${pathWithoutFragment}#${newFragment}`);
我的代码在这里。我只能使用Angular乐器或者我需要使用History API吗?谢谢!
正如@IngoBürk在评论中提到的,您可以在不使用skiplocationChange的情况下获得相同的结果
this.router.replaceUrl('path')
skipLocationChange
在不将新状态推入历史的情况下进行导航。
this.router.navigateByUrl([`${pathWithoutFragment}#${newFragment}`], { skipLocationChange: true });
参考:https://angular.io/api/router/NavigationExtras#skipLocationChange