带有 ionic 2 生产版本的 OpenWeatherMap 出错

Error with OpenWeatherMap with ionic 2 Production build

我正在尝试使用 angular 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');
    }

有什么帮助吗?

经过一段时间的测试,我遇到了和你一样的问题。我认为这是 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 产品中测试过,它工作正常