我有一个连接多个组件的路由器。每个组件都可以修改路由,以便保留其状态(复制粘贴给某人等)。
示例:
/route/mycomp
- 玩一些领域
- 路线变为
/route/mycomp;field=value
- 点击
/route/othercomp
,路线适应 - 点击
/route/mycomp
- 路由变为
route/mycomp
我希望它保留 /route/mycomp;field=value
,因为组件本身没有改变。
我尝试过:
- 更改我的 RouteReuseStrategy 实现
- 在每个过滤器操作之后在每个组件中保存网址
- 更改 DOM
有什么想法吗?
Angular 2.3.1。
最佳答案
您可以使用“skipLocationChange”
<a [routerLink]='xxx' skipLocationChange>next</a>
或
router.navigateByUrl('xxx', {skipLocationChange:true}
引用:https://angular.io/docs/ts/latest/api/router/index/NavigationExtras-interface.html
关于angular - 在组件之间导航时保持路线一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44132206/