【发布时间】:2019-11-05 11:37:25
【问题描述】:
尝试ionic cordova build android --prod --release 尝试准备应用程序以进行部署。
我遇到了一个我试图修复的错误。
最初收到的错误是
输入 SecondPage in longlocation/second/second.ts 是 的一部分 2 个模块的声明:longlocation/src/app/app.module.ts 中的 AppModule 和 在 longlocation/src/pages/second/second.module.ts 中的 SecondPageModule! 请 考虑将 longlocation/src/pages/second/second.ts 中的 SecondPage 移动到 更高 在 longlocation/src/app/app.module.ts 中导入 AppModule 的模块和 longlocation/src/pages/second/second.module.ts 中的 SecondPageModule。
我从
中删除了提到的组件声明
按照另一个 stackoverflow 答案的指示。
现在我收到另一个错误提示
模块“AppModule”导入的意外指令“SecondPage”。 请添加@ngmodule注解
我的代码是
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { SecondPage } from '../pages/second/second';
import { SendtextPage } from '../pages/sendtext/sendtext';
import { SMS } from '@ionic-native/sms';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [
MyApp,
HomePage,
//SecondPage,
//SendtextPage
],
imports: [
BrowserModule,
HttpClientModule,
SecondPage,
SendtextPage,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
SecondPage,
SendtextPage
],
providers: [
StatusBar,
SplashScreen,
SMS,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
Ionic 框架:3.9.2 Ionic App 脚本:3.2.1 Angular Core: 5.2.11 Angular 编译器 CLI:5.2.11 节点:10.6.0
非常感谢任何帮助。
【问题讨论】:
-
尝试将它们添加到
declarations和entryComponents -
为什么你的app模块的
imports数组中有页面组件?只有模块应该在那里声明。 -
原来不存在。我在那里添加它以消除另一个错误。这反过来又导致了这一点。还提到了原来的错误。
-
您是否尝试将它们添加到
declarations和entryComponents -
@Abdulrahman 原来的代码就是这样。我收到错误“在 /longdirectory/src/pages/second/second.ts 中键入 SecondPage 是 2 个模块声明的一部分:AppModule 和 SecondPageModule。请考虑将 SecondPage 移动到导入 AppModule 和 SecondPageModule 的更高模块”。跨度>
标签: angular typescript ionic-framework ionic3