bugfix> android > 投稿

Sony Z2スマートフォンでアプリを実行しようとしています。次のコマンドを使用します。

ionic build android --prod --release

コンソールで次のようなエラーが表示されます。

typescript error Type CirckelmovementPage in C:/Users/fearcoder/Documents/natuurkundeformules/src/pages/circkelmovement/circkelmovement.ts is part of the declarations of 2 modules: AppModule in C:/Users/fearcoder/Documents/natuurkundeformules/src/app/app.module.ts and CirckelmovementPageModule in C:/Users/fearcoder /Documents/natuurkundeformules/src/pages/circkelmovement/circkelmovement.module.ts!


     Please consider moving CirckelmovementPage in

  

C:/Users/fearcoder/Documents/natuurkundeformules/src/pages/circkelmovement/circkelmovement.ts           AppModuleをインポートする上位モジュールに C:/Users/fearcoder/Documents/natuurkundeformules/src/app/app.module.ts           およびCirckelmovementPageModule in C:/Users/fearcoder/Documents/natuurkundeformules/src/pages/circkelmovement/circkelmovement.module.ts。

     You can also create a new NgModule that exports and includes

  

CirckelmovementPage in C:/Users/fearcoder/Documents/natuurkundeformules/src/pages/circkelmovement/circkelmovement.ts 次に、そのNgModuleをインポートします             C:/Users/fearcoder/Documents/natuurkundeformules/src/app/app.module.tsのAppModuleで

     and CirckelmovementPageModule in

  

C:/Users/fearcoder/Documents/natuurkundeformules/src/pages/circkelmovement/circkelmovement.module.ts。

これらはファイルです

circkelmovement.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AdMobFree, AdMobFreeBannerConfig } from '@ionic-native/admob-free';
@IonicPage()
@Component({
  selector: 'page-circkelmovement',
  templateUrl: 'circkelmovement.html',
})
export class CirckelmovementPage {
  ray:any;
  circulationtime:any;
  result:any;
  constructor(public navCtrl: NavController, public navParams: NavParams, private admob: AdMobFree) {
  } 
  ionViewDidLoad(){
    const bannerConfig: AdMobFreeBannerConfig = {
      isTesting: true,
      autoShow: true
    };
    this.admob.banner.config(bannerConfig);
    this.admob.banner.prepare()
      .then(() => {
        this.admob.banner.show()
      })
      .catch(e => console.log(e));
  }
  calculateWebSpeed(ray, circulationtime){      
    return this.result = "Baansnelheid: " + (2 * Math.PI * ray / circulationtime) + " m/s";    
  }
}

app.module.ts

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 { AdMobFree } from '@ionic-native/admob-free';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { SpeedPage } from '../pages/speed/speed';
import { DistancePage } from '../pages/distance/distance';
import { TimePage } from '../pages/time/time';
import { WorkPage } from '../pages/work/work';
import { KinenergyPage } from '../pages/kinenergy/kinenergy';
import { GravityenergyPage } from '../pages/gravityenergy/gravityenergy';
import { GravityforcePage } from '../pages/gravityforce/gravityforce';
import { CirckelmovementPage } from '../pages/circkelmovement/circkelmovement';
import { ElectricityenergyPage } from '../pages/electricityenergy/electricityenergy';
import { LawohmPage } from '../pages/lawohm/lawohm';
import { LenslawPage } from '../pages/lenslaw/lenslaw';
import { LorentzforcewirePage } from '../pages/lorentzforcewire/lorentzforcewire';
import { DensityPage } from '../pages/density/density';
import { PressurePage } from '../pages/pressure/pressure';
import { LensstrenghtPage } from '../pages/lensstrenght/lensstrenght';
import { PowerPage } from '../pages/power/power';
import { CurrentstrenghtPage } from '../pages/currentstrenght/currentstrenght';
import { FrequencyPage } from '../pages/frequency/frequency';
import { WavespeedPage } from '../pages/wavespeed/wavespeed';
import { MassPage } from '../pages/mass/mass';
import { LorentzparticlePage } from '../pages/lorentzparticle/lorentzparticle';
@NgModule({
  declarations: [
    MyApp,
    HomePage,
    SpeedPage,
    DistancePage,
    TimePage,
    WorkPage,
    KinenergyPage,
    GravityenergyPage,
    GravityforcePage,
    CirckelmovementPage,
    ElectricityenergyPage,
    LawohmPage,
    LenslawPage,
    LorentzforcewirePage,
    DensityPage,
    PressurePage,
    LensstrenghtPage,
    PowerPage,
    CurrentstrenghtPage,
    FrequencyPage,
    WavespeedPage,
    MassPage,  
    LorentzparticlePage       
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    SpeedPage,
    DistancePage,
    TimePage,
    WorkPage,
    KinenergyPage,
    GravityenergyPage,
    GravityforcePage,
    CirckelmovementPage,
    ElectricityenergyPage,
    LawohmPage,
    LenslawPage,
    LorentzforcewirePage,
    DensityPage,
    PressurePage,
    LensstrenghtPage,
    PowerPage,
    CurrentstrenghtPage,
    FrequencyPage,
    WavespeedPage,
    MassPage,   
    LorentzparticlePage    
  ],
  providers: [
    StatusBar,
    SplashScreen,
    AdMobFree,
    InAppBrowser,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

circkelmovement.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { CirckelmovementPage } from './circkelmovement';
@NgModule({
  declarations: [
    CirckelmovementPage,
  ],
  imports: [
    IonicPageModule.forChild(CirckelmovementPage),
  ],
})
export class CirckelmovementPageModule {}

このコマンドを読んで、アプリをロードする際のパフォーマンスの問題を解決しました。何が間違っているのか分かりません。誰かが私を正しい方向に向けることができますか?

敬具

回答 1 件
  • したがって、遅延ロードされたページを使用する場合、フォルダー内の独自のモジュールの一部になるため、このapp.module.tsでインポートまたは宣言する必要はまったくありません。そのため、すべての遅延読み込みページには次のものがあります。

    ページの遅延読み込みページ独自の名前付きモジュールファイル(この特定のページ用に持っているようです)

    このようなページをロードするとき(たとえばnavCtrlを使用)、アプリのロジックで、ページの名前をコンポーネントとしてではなく文字列として使用する必要があります

    したがって、コードで、遅延ロードするページのコメントを外します。

    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 { AdMobFree } from '@ionic-native/admob-free';
    import { InAppBrowser } from '@ionic-native/in-app-browser';
    import { MyApp } from './app.component';
    import { HomePage } from '../pages/home/home';
    import { SpeedPage } from '../pages/speed/speed';
    import { DistancePage } from '../pages/distance/distance';
    import { TimePage } from '../pages/time/time';
    import { WorkPage } from '../pages/work/work';
    import { KinenergyPage } from '../pages/kinenergy/kinenergy';
    import { GravityenergyPage } from '../pages/gravityenergy/gravityenergy';
    import { GravityforcePage } from '../pages/gravityforce/gravityforce';
    // import { CirckelmovementPage } from '../pages/circkelmovement/circkelmovement';
    import { ElectricityenergyPage } from '../pages/electricityenergy/electricityenergy';
    import { LawohmPage } from '../pages/lawohm/lawohm';
    import { LenslawPage } from '../pages/lenslaw/lenslaw';
    import { LorentzforcewirePage } from '../pages/lorentzforcewire/lorentzforcewire';
    import { DensityPage } from '../pages/density/density';
    import { PressurePage } from '../pages/pressure/pressure';
    import { LensstrenghtPage } from '../pages/lensstrenght/lensstrenght';
    import { PowerPage } from '../pages/power/power';
    import { CurrentstrenghtPage } from '../pages/currentstrenght/currentstrenght';
    import { FrequencyPage } from '../pages/frequency/frequency';
    import { WavespeedPage } from '../pages/wavespeed/wavespeed';
    import { MassPage } from '../pages/mass/mass';
    import { LorentzparticlePage } from '../pages/lorentzparticle/lorentzparticle';
    @NgModule({
      declarations: [
        MyApp,
        HomePage,
        SpeedPage,
        DistancePage,
        TimePage,
        WorkPage,
        KinenergyPage,
        GravityenergyPage,
        GravityforcePage,
        // CirckelmovementPage,
        ElectricityenergyPage,
        LawohmPage,
        LenslawPage,
        LorentzforcewirePage,
        DensityPage,
        PressurePage,
        LensstrenghtPage,
        PowerPage,
        CurrentstrenghtPage,
        FrequencyPage,
        WavespeedPage,
        MassPage,  
        LorentzparticlePage       
      ],
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp)
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        HomePage,
        SpeedPage,
        DistancePage,
        TimePage,
        WorkPage,
        KinenergyPage,
        GravityenergyPage,
        GravityforcePage,
        // CirckelmovementPage,
        ElectricityenergyPage,
        LawohmPage,
        LenslawPage,
        LorentzforcewirePage,
        DensityPage,
        PressurePage,
        LensstrenghtPage,
        PowerPage,
        CurrentstrenghtPage,
        FrequencyPage,
        WavespeedPage,
        MassPage,   
        LorentzparticlePage    
      ],
      providers: [
        StatusBar,
        SplashScreen,
        AdMobFree,
        InAppBrowser,
        {provide: ErrorHandler, useClass: IonicErrorHandler}
      ]
    })
    export class AppModule {}
    
    

    もう1つは、アプリの命名規則に注意してください。私はここにそれを見る:

    @Component({
      selector: 'page-circkelmovement',
      templateUrl: 'circkelmovement.html',
    })
    
    

    異なるセレクターとテンプレートurlファイルの命名があります。これはあなたを噛むことができます;) これをガイダンスとして使用します:https://angular.io/guide/styleguideまたはIonicが提案する方法の例に従いますが、理想的にはファイルの命名に一貫性を持たせます:

    publish.page.html

    publish.page.module.ts

    publish.page.scss

    publish.page.ts

あなたの答え