为什么在通过子路由导航时激活父路由器?

Why parent router is activated when navigating through child routes?

我有一个带有嵌套路由器出口的简单应用程序,我的问题是如何在导航内部子路由时禁用父路由器出口的 "re-initialization"?

现在我正在为我的页面更改设置动画(在自定义路由器插座内),但即使在我浏览子页面时,我的根页面也会设置动画并且看起来很奇怪。

任何帮助将不胜感激:)

你可以实施CanReuse

通过添加

routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction) { return true; }

您告诉 Angular 在更新路由时重用该组件(如果您离开该组件并再次返回则不起作用。