我在构建期间遇到错误但是,它在浏览器中运行正常。
打字稿错误 在C:/ Users / GTP SYSTEM 2 / Projects / Ionic / dial2us / src / pages / bill / bill.ts中键入BillPage是 2个模块的声明:C:/ Users / GTP SYSTEM 2中的AppModule / Projects / Ionic / dial2us / src / app / app.module.ts 和C:/ Users / GTP SYSTEM 2 / Projects / Ionic / dial2us / src / pages / bill / bill.module.ts中的BillPageModule!请 考虑将C:/ Users / GTP SYSTEM 2 / Projects / Ionic / dial2us / src / pages / bill / bill.ts中的BillPage移动到更高的位置 在C:/ Users / GTP SYSTEM 2 / Projects / Ionic / dial2us / src / app / app.module.ts中导入AppModule的模块 BillPageModule在C:/ Users / GTP SYSTEM 2 / Projects / Ionic / dial2us / src / pages / bill / bill.module.ts。你也可以 创建一个新的NgModule,它导出并包含C:/ Users / GTP SYSTEM中的BillPage 2 / Projects / Ionic / dial2us / src / pages / bill / bill.ts然后在C:/ Users / GTP中导入AppModule中的NgModule C:/ Users / GTP SYSTEM中的SYSTEM 2 / Projects / Ionic / dial2us / src / app / app.module.ts和BillPageModule 2 /项目/离子/ dial2us / SRC /页/票据/ bill.module.ts。
我的bill.module.ts文件是:
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { BillPage } from './bill';
@NgModule({
declarations: [
BillPage,
],
imports: [
IonicPageModule.forChild(BillPage),
],
})
export class BillPageModule {}
app.module.ts 文件是:
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { MyApp } from './app.component';
import { HttpModule } from '@angular/http';
import { HttpClientModule} from '@angular/common/http';
import { LoginPage } from '../pages/login/login';
import { HomePage } from '../pages/home/home';
import { BillPage } from '../pages/bill/bill';
import { ListPage } from '../pages/list/list';
import { RegisterPage } from '../pages/register/register';
import { ForgotPassPage } from '../pages/forgot-pass/forgot-pass';
import { BillDetailsPage } from '../pages/bill-details/bill-details';
import { ComplaintListPage } from '../pages/complaint-list/complaint-list';
import { RegisterComplaintPage } from '../pages/register-complaint/register-complaint';
import { ComplaintDetailsPage } from '../pages/complaint-details/complaint-details';
// import { AuthServiceProvider } from '../providers/auth-service/auth-service';
@NgModule({
declarations: [
MyApp,
LoginPage,
HomePage,
ListPage,
RegisterPage,
ForgotPassPage,
BillPage,
BillDetailsPage,
ComplaintListPage,
RegisterComplaintPage,
ComplaintDetailsPage
],
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
HttpModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
ListPage,
LoginPage,
RegisterPage,
ForgotPassPage,
BillPage,
BillDetailsPage,
ComplaintListPage,
RegisterComplaintPage,
ComplaintDetailsPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
]
})
export class AppModule {}
答案 0 :(得分:1)
由于您未使用lazy-load
:
您甚至不需要bill.module
,您可以完全删除它并且仍然有效
然后删除所有对bill.module.ts
的引用,因为您删除了它。
您收到此错误的一般情况是在多个模块中发出component
声明,
为此,解决方案可以billPages
已经在app.module
,因为您也在条目组件中使用它,无需再次在bill.module.ts
您的bill.module.ts文件变为:
import { NgModule } from '@angular/core';
import { BillPage } from './bill';
@NgModule({
declarations: [
],
imports: [
],
})
export class BillPageModule {}
由于没有使用它,您可以像我之前所说的那样删除它。