我已将我的 Angular 应用从 Angular 15 更新到 16。 我遇到了一些节点包的编译错误,我解决了它们。 即使在那之后,仍然会出现许多错误,如下所示 ngserve
error NG8004: No pipe found with name 'txtTranslate'
error NG8002: Can't bind to 'src' since it isn't a known property of 'svg-icon'.
1. If 'svg-icon' is an Angular component and it has 'src' input, then verify that it is part of this module.
2. If 'svg-icon' 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.
75 <svg-icon class="width100" src="{{'eca_phone' | imgTranslate}}" [class]="'icon-size-10 icon-color'" [applyClass]=true></svg-icon>
我有一个sharedModule和appModule,并在两者中导入了commonModule。 这个自定义 txtTrsnalate 管道也在两者中声明。
@NgModule({
declarations: [...]
imports: [
CommonModule,
BrowserModule,
HttpClientModule,
CoreModule,
SharedModule,
FormsModule,
ReactiveFormsModule,
BrowserAnimationsModule,
ToastyModule.forRoot(),
AccordionModule.forRoot(),
CollapseModule.forRoot(),
ColorPickerModule,
AngularMyDatePickerModule,
AngularDraggableModule,
NgDragDropModule.forRoot(),
UiSwitchModule,
NgIdleModule.forRoot(),
ScrollingModule,
MsiCommonModule,
NgbModule,
AngularSvgIconModule.forRoot(),
TranslocoRootModule
]
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
bootstrap: [DockContainerComponent]
})
export class AppModule { }
import {TxtTranslatePipe} from './resource/txt-translate.pipe';
@NgModule({
imports: [
CommonModule,
BrowserAnimationsModule,
FormsModule,
...
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
declarations: [
LoginModalComponent,
TxtTranslatePipe,
...
],
exports: [
LoginModalComponent,
TxtTranslatePipe,
...
],
})
export class SharedModule { }
有时,问题的根本原因位于流程的上游。编译阶段各个组件的故障可能会级联,导致整个模块的故障。您可以检查 SharedModule 或 CommonModule 中的每个单独组件