未捕获(承诺):QuotaExceededError Ionic 3

时间:2018-06-07 18:48:39

标签: ionic3 local-storage angular5 quota ionic-storage

StackOverflow已经有了这个类型的问题,但没有一个答案对我有帮助, 以下是我的问题详情 - 我在Android设备上构建应用程序时出错,它在模拟器和浏览器中运行良好,但是当我将应用程序运行到设备中时,我收到此错误,我的数据无法保存在存储中。

vendor.js:1 ERROR Error: Uncaught (in promise): QuotaExceededError
    at c (polyfills.js:3)
    at polyfills.js:3
    at polyfills.js:3
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (vendor.js:1)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (vendor.js:1)

这是我的依赖

 "dependencies": {
"@angular/animations": "5.2.10",
"@angular/common": "5.2.10",
"@angular/compiler": "5.2.10",
"@angular/compiler-cli": "5.2.10",
"@angular/core": "5.2.10",
"@angular/forms": "5.2.10",
"@angular/http": "5.2.10",
"@angular/platform-browser": "5.2.10",
"@angular/platform-browser-dynamic": "5.2.10",
"@ionic-native/camera": "^4.7.0",
"@ionic-native/core": "4.7.0",
"@ionic-native/network": "^4.7.0",
"@ionic-native/onesignal": "^4.7.0",
"@ionic-native/splash-screen": "4.7.0",
"@ionic-native/status-bar": "4.7.0",
"@ionic-native/transfer": "^3.14.0",
"@ionic/pro": "1.0.20",
"@ionic/storage": "^2.1.3",
"cordova-android": "^7.0.0",
"cordova-ios": "4.5.4",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.2.1",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.3.2",
"emulator": "0.1.0",
"ionic-angular": "3.9.2",
"ionic-cache": "^3.0.1",
"ionicons": "3.0.0",
"onesignal-cordova-plugin": "^2.4.1",
"rxjs": "5.5.10",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.26"
}

这是我的app.module.ts导入数组

imports: [
BrowserModule,
LoginPageModule,
SignupPageModule,
DashboardPageModule,
TabPageModule,
IonicModule.forRoot(MyApp, {
  tabsPlacement: 'bottom',
  platforms: {
    ios: {
      tabsPlacement: 'bottom'
    }
  }
}),
CacheModule.forRoot(),
IonicStorageModule.forRoot({
  name: '__mydb',
  driverOrder: ['indexeddb', 'sqlite', 'websql']
}),
HttpClientModule,
],

我想在用户登录成功时保存数据,这是我的用户登录代码并将用户保存到存储中。

this.authService.userLogin(this.user)
    .subscribe(
      response => {
        console.log(response);
        console.log(typeof response.status);
        if (response.status === "ok") {
          spinner.dismiss();
          console.log(response.status);
          this.storage.ready().then(() => {
            this.storage.set('user',response);
          });

          this.navCtrl.setRoot(DashboardPage);
        } else {
          spinner.dismiss();
          console.log(response.status);
          let alert = this.alertCtrl.create({
            title: response.status,
            subTitle: response.msg,
            buttons: ['Dismiss']
          });
          alert.present()
        }
      })

正确的方向将受到高度赞赏。感谢

2 个答案:

答案 0 :(得分:1)

或者,您可以尝试在app.module.ts

中添加此行
IonicStorageModule.forRoot({
  name: ‘__mydb’,
  driverOrder: [‘sqlite’, ‘websql’, ‘indexeddb’]
})

答案 1 :(得分:1)

我尝试了一些解决方案,在这里我提到其中之一:

IonicStorageModule.forRoot({
  name: ‘__mydb’,
  driverOrder: [‘sqlite’, ‘websql’, ‘indexeddb’]
})

但这对我不起作用。

之后 我只是使用ionic native storage解决它。

它在android和ios上都能正常工作。