无法创建表SQLite Ionic 3

时间:2018-11-06 07:01:19

标签: sqlite ionic3

在使用带有离子3的SQLite创建表时出现错误。您可以看到错误屏幕截图。该如何解决?

createTable() {
    this.sqlite.create({
      name: 'data.db',
      location: 'default'
    })
      .then((db: SQLiteObject) => {
        db.executeSql('create table danceMoves(name VARCHAR(32))', {})
          .then(() => alert('table created'))
          .catch(e => alert('table not created'));
      })
      .catch(e => console.log(e));
}

enter image description here

错误详细信息工具提示:

  

类型{}的参数不能分配给类型any []的参数。 {}

类型缺少属性长度

enter image description here

1 个答案:

答案 0 :(得分:0)

根据@ionic-native/sqlite代码:

@CordovaInstance()
  executeSql(statement: string, params?: any[]): Promise<any> {
    return;
  }

第二个参数是数组类型而不是对象。试试:

db.executeSql('create table danceMoves(name VARCHAR(32))', [])
      .then(() => alert('table created'))
      .catch(e => alert('table not created'));

更新: 提交了pull request来修复文档。