我正在尝试使用react-native-sqlite-storage来处理ios上的react native上的本地数据库。
var SQLite = require('react-native-sqlite-storage');
var db = [];
export default class DataBase {
constructor () {
db = SQLite.openDatabase("eventHelper.db", "1.0", "EventHelper", 200000, this.openCB, this.errorCB);
}
errorCB(err) {
console.log("SQL Error: " + err);
}
successCB() {
console.log("SQL executed fine");
}
openCB() {
console.log("Database OPENED");
}
}
但我收到以下错误消息:无法读取未定义的属性“open”。 我不知道 openDatabase 是如何工作的,我还没有创建数据库。我不确定是否应该首先创建数据库,以及如何创建数据库,或者如果数据库不存在,openDatabase 是否会执行此操作。
我寻找了这个问题,并尝试了此处建议的解决方案 https://github.com/andpor/react-native-sqlite-storage/issues/64 - 卸载了react-native-sqlite-storage - 删除了node_modules文件夹 - npm安装 - npm安装--保存react-native-sqlite-storage - rnpm 链接
任何建议都将受到高度赞赏。谢谢!
最佳答案
安装 SQLite 插件后,您是否重新运行了react-native run-ios? 我遇到了同样的错误并修复了它,希望它有帮助
关于ios - 从ios打开react-native-sqlite-storage数据库时无法读取未定义的属性 'open',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41977528/