IONIC2 - 无法读取属性' forRoot'未定义的#120

时间:2017-07-18 10:07:42

标签: angular ionic-framework

我刚刚将离子存储升级到2.0.0,并遵循此处给出的说明https://github.com/ionic-team/ionic-storage/releases/tag/v2.0.0

当我运行我的应用程序时,它表示无法读取属性' forRoot'未定义的

错误: -

Runtime Error
Cannot read property 'forRoot' of undefined
Stack
TypeError: Cannot read property 'forRoot' of undefined
    at http://localhost:8100/build/main.js:14328:83
    at Object.<anonymous> (http://localhost:8100/build/main.js:14354:2)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:93334:80)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:117157:70)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at http://localhost:8100/build/main.js:66:18
    at http://localhost:8100/build/main.js:69:10

我的app.module.ts

import { IonicStorageModule } from '@ionic/storage';

@NgModule({
  declarations: [
    TruncatePipe,
    TrimHtmlPipe
  ],
  imports: [
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot({
      name: '__mydb',
         driverOrder: ['indexeddb', 'sqlite', 'websql']
    }),
    CommonModule,
    HttpModule,
    TranslateModule.forRoot({ 
      provide: TranslateLoader,
      useFactory: (createTranslateLoader),
      deps: [Http]
    }),
  ],
  exports: [
    IonicModule,
    TranslateModule,
    TruncatePipe,
    TrimHtmlPipe
  ],
  providers: [
    Config //,    Storage
  ]
})

我的package.json: -

{
  "name": "MyApp",
  "author": "Sanny Srivastava",
  "homepage": "example.com",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic-native/core": "^3.6.1",
    "@ionic-native/device": "^3.13.0",
    "@ionic-native/facebook": "^3.14.0",
    "@ionic-native/geolocation": "^3.13.1",
    "@ionic-native/push": "^3.13.0",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/storage": "2.0.0",
    "angular2-google-maps": "^0.16.0",
    "chart.js": "^2.5.0",
    "ionic-angular": "2.1.0",
    "ionic-cache": "^2.0.5",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "moment": "2.15.1",
    "ng2-translate": "^3.1.3",
    "rxjs": "5.0.0-beta.12",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.1.3",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard",
    "cordova-plugin-crosswalk-webview",
    "cordova-plugin-inappbrowser",
    "cordova-plugin-x-socialsharing",
    "phonegap-plugin-barcodescanner",
    {
      "variables": {
        "APP_ID": "*************************",
        "APP_NAME": "MyAppApp"
      },
      "locator": "cordova-plugin-facebook4@1.7.1",
      "id": "cordova-plugin-facebook4"
    },
    "cordova-plugin-email"
  ],
  "cordovaPlatforms": [],
  "description": "MyApp"
}

请帮忙。

谢谢Sanny

0 个答案:

没有答案