我正在尝试使用角度2和TS构建一个ionic2应用程序,构建处于生产模式,我收到此错误。
Error: Unexpected value 'OpenWeatherMapModule in E:/Stage/VLT
APP/com.vlt.app/node_modules/ionic-
openweathermap/dist/openweathermap.module.d.ts' imported by the module
'AppModule in E:/Stage/VLT APP/com.vlt.app/src/app/app.module.ts'.
Please add a @NgModule annotation.
Error: Unexpected value 'OpenWeatherMapModule in E:/Stage/VLT
APP/com.vlt.app/node_modules/ionic-
openweathermap/dist/openweathermap.module.d.ts' imported by the module
'AppModule in E:/
Stage/VLT APP/com.vlt.app/src/app/app.module.ts'. Please add a @NgModule
annotation.
我在我的应用程序中使用OpenWeatherMap,我不知道为什么我只在生产模式下出现此错误。此外我不认为我需要编辑节点模块库目录中的任何文件。
修改
这是app.module.ts中的我的进口数组
@NgModule({
declarations: [
MyApp,
HomePage,
ListPage,
BestOffers,
excursion,
hotel,
circuit,
MapPage,
NosExcursion,
WeatherPage,
NosHotel,
NosCircuit,
CircuitPage,
ExcursionPage,
ImageModal,
SearchModal,
ResultModal,
PromoPage,
HotelPage,
GalleryPage,
GalleryModal,
ZoomableImage,
PopoverPage,
ReservationModal,
CurrencyChange,
CircuitReservationModal,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpModule,
IonicStorageModule.forRoot(),
SuperTabsModule.forRoot(),
AgmCoreModule.forRoot({
apiKey: '**********'
}),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http]
}
}),
IonicImageViewerModule,
OpenWeatherMapModule,
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
ListPage,
BestOffers,
excursion,
hotel,
circuit,
MapPage,
NosExcursion,
WeatherPage,
NosHotel,
NosCircuit,
CircuitPage,
HotelPage,
ExcursionPage,
ImageModal,
SearchModal,
ResultModal,
PromoPage,
GalleryPage,
GalleryModal,
PopoverPage,
ReservationModal,
CurrencyChange,
CircuitReservationModal,
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
SQLite,
HotelPage,
InAppBrowser,
]
})
export class AppModule {}
export function createTranslateLoader(http: Http) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
那么有什么帮助吗?
答案 0 :(得分:3)
经过一段时间的测试后,我遇到了和你一样的问题。我认为这是openweathermap模块的问题。此模块中的文件结构似乎不正确。
因此,我不需要安装此模块,而是下载源代码并包含在我的离子样本中,如下所示:
home.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<openweathermap [options]="options"></openweathermap>
</ion-content>
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
options: any = {};
constructor(public navCtrl: NavController) {
this.options = {
apikey: "6ff5deed8aaa46c2fdcb1bfddd2d4ecc",
city: { "name": ["Phnom Penh"] },
unitFormat: "metric",
lang: "en"
}
}
}
此示例的源代码可在此处找到:ionic3-openweathermap
我希望这可以帮助你,谢谢:)
编辑
我在Android制作中测试过,它运行良好