TypeError: undefined is not an object (evaluating 'pluginObj._objectInstance') IONIC 2

TypeError: undefined is not an object (evaluating 'pluginObj._objectInstance') IONIC 2

通常当我看到这样的消息时,引号内的对象通常是我编码的对象。但在这种情况下,我不太熟悉 pluginObj._objectInstance 是因为调试这是相当困难的。我在网上看了看,除了实际的源代码没有告诉我杰克,因为我还是新手,所以在上面找不到任何东西。

TypeError: undefined is not an object (evaluating 'pluginObj._objectInstance')

我正在使用 ionic 2 并从 sqlite 中获取数据(如果有帮助的话)。错误出现在 xcode

我找到了那个问题的一个令人毛骨悚然的解决方案,它在 Android 和 iOS

中仍然有效

文档说: 在打开的数据库上执行 SQL。注意,必须先调用openDatabase,并确保其解析并成功打开数据库。

由于某种原因,数据库没有打开成功,请重新打开

public database: SQLite;

this.database = new SQLite();

this.database.openDatabase({name: "data.db", location: "default"}).then(() => {

this.database.executeSql('Insert statement', []).then((data) => {

}, (error) => {
    console.log("ERROR insert: " + error);
});
}, (error) => {
console.log("ERROR open database: ", error);
});

同时我在三个离子论坛上花费了最终答案:https://forum.ionicframework.com/t/sqlite-cant-executesql/66575/8