一、安装Data Storage
官方文档 https://ionicframework.com/docs/angular/storage
ionic cordova plugin add cordova-sqlite-storage
npm install --save @ionic/storage
二、声明【app.module.ts】
import { IonicStorageModule } from '@ionic/storage';
@NgModule({
declarations: [
// ...
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
// ...
],
providers: [
// ...
]
})
export class AppModule {}
三、运用
import { Storage } from '@ionic/storage';
export class MyApp {
constructor(private storage: Storage) { }