如何解决运行时错误:TypeError:无法读取未定义的属性“就绪”?

时间:2019-04-26 20:22:48

标签: runtime-error

app.component.ts

if (.not. present(optionalArg)) then
    optionalArg = 2
end if

1 个答案:

答案 0 :(得分:0)

请确保您对构造函数中注入的东西的引用与您在方法中调用它们的引用相同。例如,您还命名了大写字母等...

import { Component, ViewChild } from '@angular/core';
import { Platform, NavController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Storage } from '@ionic/Storage';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';

import { RegisterPage } from '../pages/register/register';

@Component({ 
    templateUrl: 'app.html' 
}) 
export class MyApp {

  @ViewChild('content') nav: NavController; 
  rootPage: any;
  initialization: any; 
  initializationApp: any;

  constructor(public platform: Platform, public statusBar:
    StatusBar, public splashScreen: SplashScreen, private storage:
      Storage) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });

    this.storage.get('session_storage').then((res) => {
      if (res == null) {
        this.rootPage = LoginPage;
      } else {
        this.rootPage = HomePage;
      }
    });
  }
}

您在构建器中初始化platform1的同时调用platform。 要修复更新您的构造函数以指向“平台”