尝试使用 angular2-json-schema-form & build in prod 时出现此错误
装饰器不支持“DemoModule”模板编译期间的错误函数调用,但调用了“JsonSchemaFormModule”。我发现错误来自:
@NgModule({
declarations: [ AceEditorDirective, DemoComponent, DemoRootComponent ],
imports: [
BrowserModule, BrowserAnimationsModule, FlexLayoutModule, FormsModule,
HttpClientModule, MatButtonModule, MatCardModule, MatCheckboxModule,
MatIconModule, MatMenuModule, MatSelectModule, MatToolbarModule,
RouterModule.forRoot(routes),
NoFrameworkModule, MaterialDesignFrameworkModule,
Bootstrap3FrameworkModule, Bootstrap4FrameworkModule,
JsonSchemaFormModule.forRoot( // the source of the Error
NoFrameworkModule,
MaterialDesignFrameworkModule,
Bootstrap3FrameworkModule,
Bootstrap4FrameworkModule
)
],
bootstrap: [ DemoRootComponent ]
})
在库的源代码中,他们使用如下内容:
export class JsonSchemaFormModule {
static forRoot(...frameworks): ModuleWithProviders {
const loadFrameworks = frameworks.length ?
frameworks.map(framework => framework.forRoot().providers[0]) :
[{ provide: Framework, useClass: NoFramework, multi: true }];
return {
ngModule: JsonSchemaFormModule,
providers: [
JsonSchemaFormService, FrameworkLibraryService, WidgetLibraryService,
...loadFrameworks
]
};
}
}
当我删除变量时,loadFramworks
我没有错误,但我似乎无法在 providers 属性中注入框架