Local storage in ionic 2 error

前端 未结 2 761
[愿得一人]
[愿得一人] 2020-12-22 05:43

I try to use this in my Ionic 2 application : https://ionicframework.com/docs/v2/storage/

I already run

cordova plugin add cordova-sqlite-storage --         


        
2条回答
  •  别那么骄傲
    2020-12-22 05:57

    Since Ionic 2.2.0, it's recommended to use @ionic/storage version 2.0.0. Configuration in app.modules.ts has changed since the previous version. The error occurs if you haven't changed everything in the right way.

    In app.modules.ts do following changes:

    1. Remove Storage from providers
    2. Change import statement:

      from: import { Storage } from '@ionic/storage';

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

    3. Add the following to the imports array:

      IonicStorageModule.forRoot()

    The import array should look like below:

    imports: [
      IonicModule.forRoot(MyApp),
      IonicStorageModule.forRoot()
    ],
    



    NOTE: Do not make any change in imports of Storage in any other files.

提交回复
热议问题