Angular2 后退按钮问题 | URL 不变 | Angular 通用

Angular2 back button issue | URL not changing | Angular Universal

有点奇怪的问题,但我不知道发生了什么。当我单击后退浏览器按钮时,页面发生变化,但 URL 保持不变。当我再次单击后退按钮时,URL 发生了变化,但页面保持不变。

使用

后已修复此问题
window.history.pushState({},'',url);

但是有了这个……问题是如果我一直点击后退按钮,我会循环 2 页。

示例:-

A -> B -> C -> (back) -> B -> (back) -> C -> (back) -> B -> (back) -> C-> (back) -> B -> (back)

注意:- 我在根路由模块中有 RouterModule.forRoot(),在子路由中有 RouterModule.forChild()。

我正在使用 angular universal

可能的问题是什么?如何解决?

------------------------------------ XXXXXX -------- --------------------------------------

更新

Was playing with code and i ran into Location of @angular/common. 
This is great with popstate (resolved the url change issue) but the problem now is...
whenever i hit back button...it pop same page twice....

示例:-

A -> B -> C -> (back) -> B -> (back) -> B -> (back) -> A -> (back) -> A 

------------------------------------ XXXXXX -------- --------------------------------------

更新 2:-

when using location.. i checked the history length... 
the history length is not changing when the back button is clicked first time...

示例:-

A : length = 1 -> B : length = 2 -> C : length = 3 -> (back) -> B : length = 3 -> (back) -> 
B : length = 2 -> (back) -> A : length = 2 -> (back) -> A : length = 1 

P.S。 -> 在询问库版本之前检查 link。

检查文件

app-routing.module.ts

并确保导入的路由像

RouterModule.forChild([])

而不是

RouterModule.forRoot([])

它将解决问题。