【问题标题】:IONIC 3 "Expected 1 arguments, but got 0"IONIC 3“预期 1 个参数,但得到 0”
【发布时间】:2017-12-11 06:04:58
【问题描述】:

我收到此错误:预期有 1 个参数,但在我的数据库提供程序中得到 0。...我正在尝试创建本地存储。

数据库.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”,但它仍然无法正常工作

【问题讨论】:

    标签: ionic-framework local-storage


    【解决方案1】:

    你可以用 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);
      }
    
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 2020-11-07
      • 2022-01-24
      • 2019-11-23
      • 2018-08-14
      • 1970-01-01
      • 2020-10-12
      • 2021-07-29
      • 2021-08-22
      相关资源
      最近更新 更多