嘿,我试图将这个库集成到我的中,但是得到了以下错误:
意外值‘/Users/.../node_modules/ngx-mui-datatables/ngx-mui-datatables.d.ts’中的NgxMuiDatatablesModule‘由模块'AppModule在/././src/app/app.module.ts’导入。请添加一个@NgModule注释。
该模块最初是在app.module.ts中导入的,软件包是通过npm安装的。
我使用的是角8.2.1,我导入的库是: 0.0.10作为我相信的最新版本。
我尝试过许多其他人在Github上建议的不同方法,但是它与这个特定的包无关,尽管编译错误是相似的:意外值.请添加一个@NgModule注释。
这是我的app.module.ts:
再说一遍,这个模块最初是在这里导入的,但是我正在探索不同的解决方案,所以您将看到一个重复的导入在我的航班管理中--.module.ts,但是它不应该是问题,因为我已经通过从app.module.中删除导入来进行测试。
... other imports omitted
import { NgxMuiDatatablesModule } from 'ngx-mui-datatables';
@NgModule( {
declarations: [
AppComponent,
HeaderComponent,
SidenavComponent,
WelcomeComponent,
LoginDialog,
ResetPasswordComponent,
AircraftRegisterComponent,
AircraftFleetComponent,
// FlightManagementComponent,
// RouteManagementComponent,
FlightRegisterComponent,
FlightChangeDialog,
ConfirmDialog,
Error401Component,
Error404Component,
InputNumberOnlyDirective
],
imports: [
BrowserModule,
BrowserAnimationsModule,
CustomStyleModule,
RouterModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
FlightManagementModule,
RouteManagementModule,
NgxMuiDatatablesModule
],
// schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
providers: [],
bootstrap: [ AppComponent ],
entryComponents: [ LoginDialog, FlightChangeDialog, ConfirmDialog ]
} )
export class AppModule {}datatable模块在几个组件中使用,因此我将其中一个组件发布以获取信息。
组件.flight:
<div class="container">
<div class="ngx-datatable-container" fxLayout="column" fxLayoutAlign="center center">
<ngx-mui-datatable title="Flight List" [data]="dataSource" [columns]="columns"
[options]="options"></ngx-mui-datatable>
</div>
</div>飞行管理模块:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FlightManagementComponent } from './flight-management.component';
import { MuiDatatablesComponent } from 'ngx-mui-datatables/ngx-mui-datatables';
@NgModule( {
declarations: [ FlightManagementComponent, MuiDatatablesComponent ],
exports: [ FlightManagementComponent ],
imports: [ CommonModule ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
} )
export class FlightManagementModule {}我的应用程序在dev环境中运行良好,使用默认-jit编译模式,但具体使用--aot失败。而且,它无法部署到prod环境,默认情况下使用--aot。
我知道在构建过程中禁用aot和compileOptimizer是有办法的,但我希望这个问题有一个实际的解决方案。由于提前禁用和优化器大大增加了构建时间。
任何帮助都是非常感谢的!
发布于 2019-09-09 02:42:23
您应该在NgxMuiDatatablesModule中导入FlightManagementModule并删除MuiDatatablesComponent的声明。
它在dev环境中运行良好,因为您在模块中使用了schemas: [ CUSTOM_ELEMENTS_SCHEMA ]。
当您删除它时,开发环境上也会出现错误。
https://stackoverflow.com/questions/57847181
复制相似问题