错误错误:未捕获(在承诺中):TypeError:undefined不是函数

问题描述 投票:1回答:1

我正在尝试使用离子项目实现Lazy Loading但是我在实现时遇到错误,我正在实现延迟加载时我得到的错误

core.js:1449 ERROR错误:未捕获(在promise中):TypeError:undefined不是函数TypeError:undefined不是函数

我将代码放在下面

app.module.ts

import { NextPageModule } from '../pages/next/next.module';
import { HomePageModule } from './../pages/home/home.module';
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';

@NgModule({
  declarations: [
    MyApp,
  ],
  imports: [
    HomePageModule,
    NextPageModule,
    BrowserModule,
    IonicModule.forRoot(MyApp),
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

app.component.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

// import { HomePage } from '../pages/home/home';
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:string = 'NextPage';

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}
angular ionic-framework ionic2 ionic3
1个回答
1
投票

解决了

我已经遭遇了很多解决这个错误,我终于找到了解决方案,我只是运行npm install @ionic/[email protected]

或者npm install @ionic/[email protected]

或者npm install @ionic/app-scripts@Version that works for you

问题不在于你的代码,它只是app-scripts版本。

© www.soinside.com 2019 - 2024. All rights reserved.