Ionic PWA Indexeddb和SQLite错误:iOS上的“找不到可用的存储方法”

时间:2019-10-02 12:22:03

标签: angular ionic-framework progressive-web-apps ionic-storage

解决了在以indexeddb或sqllite作为关联数据库(在app.module.ts中)在iOS Safari上作为浏览器pwa运行离子样品选项卡应用程序时出现的问题。它也发生在Chrome iOS开发人员视图中。相比之下,该错误不会在Chrome桌面或Android上发生。

Chrome控制台中的错误日志;

  

core.js:9110错误错误:未捕获(承诺中):错误:无可用   找到存储方法。错误:找不到可用的存储方法。       在localforage.js:2743       在ZoneDelegate.invoke(zone-evergreen.js:359)       在Object.onInvoke(core.js:34201)       在ZoneDelegate.invoke(zone-evergreen.js:358)       在Zone.run(zone-evergreen.js:124)       在zone-evergreen.js:855       在ZoneDelegate.invokeTask(zone-evergreen.js:391)       在Object.onInvokeTask(core.js:34182)       在ZoneDelegate.invokeTask(zone-evergreen.js:390)       在Zone.runTask(zone-evergreen.js:168)       在resolvePromise(zone-evergreen.js:797)       在zone-evergreen.js:707       在ionic-storage.js:127       在ZoneDelegate.invoke(zone-evergreen.js:359)       在Object.onInvoke(core.js:34201)       在ZoneDelegate.invoke(zone-evergreen.js:358)       在Zone.run(zone-evergreen.js:124)       在zone-evergreen.js:855       在ZoneDelegate.invokeTask(zone-evergreen.js:391)       在Object.onInvokeTask(core.js:34182)

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { IonicStorageModule } from '@ionic/storage';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,IonicStorageModule.forRoot({
    name: '__mydb',
    driverOrder: ['indexeddb', 'sqlite']
  })],  
  providers: [
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

package.json

{
  "name": "db-test",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/core": "~8.1.2",
    "@angular/forms": "~8.1.2",
    "@angular/platform-browser": "~8.1.2",
    "@angular/platform-browser-dynamic": "~8.1.2",
    "@angular/router": "~8.1.2",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.7.1",
    "@ionic/storage": "^2.2.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.801.2",
    "@angular-devkit/build-angular": "~0.801.2",
    "@angular-devkit/core": "~8.1.2",
    "@angular-devkit/schematics": "~8.1.2",
    "@angular/cli": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/compiler-cli": "~8.1.2",
    "@angular/language-service": "~8.1.2",
    "@ionic/angular-toolkit": "~2.0.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "An Ionic project"
}

这是怎么了? iOS WebView不支持indexeddb和sqlite吗?

作为一种解决方法,我们卸载了ionic-storage并使用了dexie.js(可以正常运行)

0 个答案:

没有答案