更新时间:2023-10-25 23:40:58
主要问题是,来自app-routing.module.ts
的routes
变量在进入error
之前具有进入**
的条目,并且路由器将始终转到**
.
Main issue is that the routes
var from the app-routing.module.ts
has the entry to **
before the entry to error
and the router will always go to **
.
将条目**
移至routes
内部的最后一个位置,将使error
条目可访问.
Moving the entry **
to the last place inside of routes
will make the error
entry reachable.
我们还发现,在更新之后,CustomErrorComponent
的@Component({})
装饰器也已删除.
Also we found that after the updates the @Component({})
decorator of the CustomErrorComponent
was removed.
让我们再次回滚,并使用以下代码保留CustomErrorComponent
文件:
Let's rollback that again and leave the CustomErrorComponent
file with this code:
import { OnInit, Component } from '@angular/core';
@Component({
selector: "customErrorComponent",
templateUrl: './customerror.component.html'
})
export class CustomErrorComponent implements OnInit {
constructor() { }
ngOnInit() {
console.log('customErrorComponent | ngOnInit...');
}
}
此外,我们还必须将CustomErrorComponent
添加到主模块的entryComponents
中.
Also we must add the CustomErrorComponent
to the entryComponents
of your main module.
只需将entryComponents: [CustomErrorComponent]
添加到您的主模块中即可.
Just add entryComponents: [CustomErrorComponent]
to your main Module.
做到了这一点,将来的读者可以检查问题的聊天主题以获取更多信息.
That did the job, future readers can check the chat thread of the question for more information.