我收到此错误:在我的数据库提供程序中预期有1个参数,但得到0。 ...我正在尝试创建本地存储。
database.ts
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable()
export class DatabaseProvider {
local : any;
constructor(public http: HttpClient) {
console.log('Hello DatabaseProvider Provider');
this.local = new Storage();
}
}
我的错误是创建新存储时的行" this.local = new Storage();" ...所以,Storage()似乎在等待争论......什么论点?我已尝试过" localstorage"但它仍无法正常工作
答案 0 :(得分:0)
您可以使用SQLite
尝试此操作import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { SQLite } from 'ionic-native';
@Injectable()
export class DatabaseProvider {
local : any;
constructor(public http: HttpClient) {
console.log('Hello DatabaseProvider Provider');
this.local = new SQLite();
}
}
或(但我相信SqlStorage已被弃用)
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Storage, SqlStorage } from '@ionic/storage';
@Injectable()
export class DatabaseProvider {
local : any;
constructor(public http: HttpClient) {
console.log('Hello DatabaseProvider Provider');
this.local = new Storage(SqlStorage);
}
}