Angular 路由器。导航不';将路由器3.0.1更新为3.4.1后不工作
我有上述路线。默认情况下,它启动HomeComponent,在构造函数中,它有一个条件来检查导致ErrorComponent的错误Angular 路由器。导航不';将路由器3.0.1更新为3.4.1后不工作,angular,typescript,Angular,Typescript,我有上述路线。默认情况下,它启动HomeComponent,在构造函数中,它有一个条件来检查导致ErrorComponent的错误 const myRoutes: Routes = [ { path: "error", component: ErrorComponent, pathMatch: "full" }, { path: "", component: HomeComponent } ]; 但是,在更新路由器之后,除了其他角度库和依赖项之外。这已经不起作用了。URL路由到
const myRoutes: Routes = [
{ path: "error", component: ErrorComponent, pathMatch: "full" },
{ path: "", component: HomeComponent }
];
但是,在更新路由器之后,除了其他角度库和依赖项之外。这已经不起作用了。URL路由到错误路径,但组件未启动。我在构造函数中有一个断点,但它没有被击中。控制台中也没有错误。我试图将ErrorComponent设置为默认页面,只是为了检查组件本身是否出错,但它实际上是加载的,只是在路径与组件关联时没有加载
不确定它是否相关,但我没有进行任何延迟加载,因此所有组件都是在一开始构建的
我查看了文档,看看是否有任何差异。我还尝试将呼叫更改为:
this.router.navigate(["/error"]);
我将路径移动到下定义的路径
this.router.navigate(["error"], { relativeTo: this.route });
//where "route" is ActivatedRoute
不知道为什么它以前能在
RouterModule.forChild()
RouterModule.forRoot()