Angular “后退”按钮仅更新url,而不是作为自定义元素导出的角度应用程序中的页面
上下文:我构建了英雄之旅应用程序,并将其导出为名为app element的自定义元素。我在本地服务器上部署了它 index.htmlAngular “后退”按钮仅更新url,而不是作为自定义元素导出的角度应用程序中的页面,angular,back-button,angular-router,html5-history,popstate,Angular,Back Button,Angular Router,Html5 History,Popstate,上下文:我构建了英雄之旅应用程序,并将其导出为名为app element的自定义元素。我在本地服务器上部署了它 index.html <head> <title>Custom Element Example</title> <base href="/"> <script type="text/javascript" src="bundled.js"></script> </head> &l
<head>
<title>Custom Element Example</title>
<base href="/">
<script type="text/javascript" src="bundled.js"></script>
</head>
<body>
<app-element></app-element>
</body>
这造成了一个新问题。它不允许我们现在按下浏览器的前进按钮,因为当我们使用router.navigate方法导航到URL时,URL将成为浏览器历史记录的新顶部
是否有任何方法可以在按下后退按钮的同时呈现页面,并且仍然可以继续
注意:当我直接部署应用程序而不将其导出为自定义元素时,上述问题都不会发生
constructor(private router:Router, private location:PlatformLocation){
location.onPopState((e)=>{
console.log(location.href);
this.router.navigate([/** fetch route from location.href */]);
})
};