美文网首页
ionic3 build之后,出现xx.ts is part o

ionic3 build之后,出现xx.ts is part o

作者: 云小诺 | 来源:发表于2018-07-09 12:04 被阅读0次

当程序写完之后,执行 ionic build --prod 的时候,
会出现xx.ts is part of the declarations of 2 modules(xx是2个模块的声明),这样的报错。

解决方式是:
在app.module.ts里面:

import { XXXModule } from '../../XXX.module'; 
 
@NgModule({
  declarations: [
    MyApp,
    ……
    // XXX,    【 在这删除 】
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    HttpModule,
     // XXX,    【 在这增加 】
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    XXX
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}, Eventdata, AuthProvider
  ]
})
export class AppModule { }

这时候,如果在XXX.ts里面有用到一些其他的组件时,需要在XXX.module.ts里面引入:
例如:

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { XXXPage } from './XXX';
import { VgCoreModule } from 'videogular2/core';
import { VgControlsModule } from 'videogular2/controls';
import { VgOverlayPlayModule } from 'videogular2/overlay-play';
import { VgBufferingModule } from 'videogular2/buffering';

@NgModule({
  declarations: [
   XXXPage,
  ],
  imports: [
    IonicPageModule.forChild(XXXPage),
    VgCoreModule,
    VgControlsModule,
    VgOverlayPlayModule,
    VgBufferingModule,
  ],
  exports: [
    ProfilePage
  ]
})
export class XXXPageModule { }

使用什么,就在当前的module.ts里面引入什么

相关文章

网友评论

      本文标题:ionic3 build之后,出现xx.ts is part o

      本文链接:https://www.haomeiwen.com/subject/xlbzuftx.html