我有一个在iframe中运行的角度应用程序。 html看起来像这样。
<html>
<body>
<iframe src="http://localhost:9999?screen=two"></iframe>
</body>
</html>
在提供的路径中,我添加了一个查询参数“ screen”。共有三个视图,路由显示如下。
const routes: Routes = [
{ path: 'one', component: OneComponent },
{ path: 'two', component: TwoComponent },
{ path: '', component: AppComponent }
];
在angular应用程序中,我已解决了要在ngOnInit()
的{{1}}中显示的组件
app.component.ts
问题是,iframe始终显示OneComponent,直到更改查询参数后重新打开选项卡。 我的问题是:
答案 0 :(得分:0)
我不确定原因为何,但是有一个修复程序可以在每次查询参数更改时自动刷新iframe
。
<script>
var _theframe = document.getElementById("theframe");
theframe.contentWindow.location.href = theframe.src;
</script>