如何修复 Angular Can't bind to 'routerLink' since it isn't a known property of
如果你看到类似这样的错误消息
error.txt
Error: src/app/my-component/my-component.component.html:2:1 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'p-button'.
1. If 'p-button' is an Angular component and it has 'routerLink' input, then verify that it is part of this module.
2. If 'p-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.在你的 Angular 应用中,打开声明你组件的模块文件(通常是 app.module.ts)并添加
app.module.ts
RouterModule,到其 imports,例如:
app.module.ts
imports: [
CommonModule,
RouterModule,
]Check out similar posts by category:
Angular
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow