ios - 从ios打开react-native-sqlite-storage数据库时无法读取未定义的属性 'open'

标签 ios sqlite react-native

我正在尝试使用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 链接

但我的构建失败 enter image description here

任何建议都将受到高度赞赏。谢谢!

最佳答案

安装 SQLite 插件后,您是否重新运行了react-native run-ios? 我遇到了同样的错误并修复了它,希望它有帮助

关于ios - 从ios打开react-native-sqlite-storage数据库时无法读取未定义的属性 'open',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41977528/

相关文章:

ios - NslocalizedString 返回键而不是值

ios - 使用BLE RSSI值进行邻近连接

react-native - 从 token 端点检索的 ID token 获取 AWS Cognito 用户

javascript - 如何将图像定义为背景? ( react native )

ios - 如何从上到下然后从左到右排列 UICollectionViewCell

iphone - 哪个服务器可以托管 iOS 推送通知

c++ - 在这种情况下如何修复 "Reference to non-static member function must be called"?

android - React Native 中的存储

c# - 任何使用 SQLite 的 Crystal Reports 工作示例?

javascript - 纯正则表达式解决方案,用于在无法依赖 document.createElement 的环境中从 HTML 字符串获取文本内容?