【发布时间】:2017-06-18 01:36:41
【问题描述】:
我正在尝试使用 react-native-sqlite-storage 与本地数据库一起使用 react native,对于 ios。
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");
}
}
但我收到以下错误消息:无法读取未定义的属性“打开”。 我不知道 openDatabase 是如何工作的,我还没有创建数据库。我不确定我是否应该首先创建数据库,以及如何创建数据库,或者如果数据库不存在,openDatabase 是否会这样做。
我寻找了这个问题,并尝试了这里建议的解决方案https://github.com/andpor/react-native-sqlite-storage/issues/64 - 卸载 react-native-sqlite-storage - 删除了 node_modules 文件夹 - npm 安装 - npm install --save react-native-sqlite-storage - rnpm 链接
我们将不胜感激任何建议。谢谢!
【问题讨论】:
标签: ios sqlite react-native