【问题标题】:ERROR Error: Uncaught (in promise): TypeError: undefined is not a functionERROR 错误:未捕获(在承诺中):TypeError:未定义不是函数
【发布时间】:2019-01-11 10:50:38
【问题描述】:

我正在尝试使用 ionic 项目实施延迟加载,但在实施时出现错误,我将错误置于实施延迟加载时遇到的错误

core.js:1449 ERROR 错误:未捕获(承诺中):TypeError:未定义 is not a function TypeError: undefined is not a function

我在下面放代码

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();
    });
  }
}

【问题讨论】:

  • 您是否将@IonicPage() 装饰器添加到NextPage 类?

标签: angular ionic-framework ionic2 ionic3


【解决方案1】:

已解决

我为解决这个错误付出了很多,我 终于找到了我刚刚的解决方案 运行npm install @ionic/app-scripts@3.1.7-201801172029

npm install @ionic/app-scripts@3.1.7

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

问题不在于您的代码,而在于应用脚本版本。

【讨论】:

  • 我不敢相信这是问题所在!!!谢谢!!!浪费了这么多时间
猜你喜欢
  • 1970-01-01
  • 2018-04-07
  • 2018-07-04
  • 2020-05-19
  • 1970-01-01
  • 2018-11-05
  • 2022-11-11
  • 2021-05-02
  • 2015-01-01
相关资源
最近更新 更多