如何以权利方式刷新 Angular 7 页面?

Posted

技术标签:

【中文标题】如何以权利方式刷新 Angular 7 页面?【英文标题】:How to refresh angular 7 page on rights way? 【发布时间】:2019-11-10 04:44:09 【问题描述】:

重新加载页面而不是路由器的正确方法是什么?

我看到了例如 window.location.reload() 但它在 s-s-r 中不是一个好习惯,对吧?

【问题讨论】:

您必须更明确地了解您的需求:Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How To Ask page for help clarifying this question. (How to Ask & minimal reproducible example) How to reload page the whole page in Angular 2?的可能重复 【参考方案1】:

没有this is the way。我正在运行一个大型应用程序,我们设置了一个 websocket 重新加载事件来强制每个客户端使用 window.location.reload(true) 重新加载应用程序,这样我们就可以构建和发布应用程序的新版本并强制每个人使用新版本,这样什么都没有。

对于角度本身,只有路由器选项:

@ngModule(
 imports: [RouterModule.forRoot(routes, onSameUrlNavigation: ‘reload’)],
 exports: [RouterModule],
 )

【讨论】:

以上是关于如何以权利方式刷新 Angular 7 页面?的主要内容,如果未能解决你的问题,请参考以下文章

在Angular 7中运行另一个Component的方法而不刷新当前页面?

如何以角度2刷新页面

创建规则以在 IIS 中刷新 angular2 应用程序的页面

如何使用 AJAX 以编程方式刷新视图页面?

VUE+NUXT项目页面刷新报错问题解决方式

AngularJS关于带有html5mode页面刷新错误的页面[重复]