【问题标题】:Error opening database, Cordova Web Browser打开数据库时出错,Cordova Web 浏览器
【发布时间】:2018-06-30 06:11:21
【问题描述】:

我正在为 ionic 2 中的应用程序创建数据库,但在我创建它的位置失败:

this.sqlite.create({
  name: 'details.db',
  location: 'default'
}).then((db: SQLiteObject) => {
    //... }

错误:

OPEN database: details.db  
Error: exec proxy not found for :: SQLitePlugin :: close
Error: exec proxy not found for :: SQLitePlugin :: open
OPEN database: details.db FAILED, aborting any pending transactions
Error: Could not open database
    at newSQLError (SQLitePlugin.js:25)
    at SQLitePlugin.js:198
    at Object.module.exports [as exec] (cordova.js:1006)
    at SQLitePlugin.js:207
    at Object.module.exports [as exec] (cordova.js:1006)
    at SQLitePlugin.open (SQLitePlugin.js:210)
    at new SQLitePlugin (SQLitePlugin.js:84)
    at Object.<anonymous> (SQLitePlugin.js:600)
    at Object.openDatabase (SQLitePlugin.js:58)
    at index.js:176

我已通过ionic cordova platform add browser 添加了 Cordova 功能。

我这样运行应用程序:

ionic cordova run browser

是否意味着浏览器中没有此cordova功能(创建数据库)?

【问题讨论】:

  • 浏览器不是移动设备。例如,当需要根据插件进行测试时,我倾向于检查我们是在真实设备中还是在浏览器上运行。您在浏览器上将拥有的最接近 sql 的东西是 websql,但它已被弃用:caniuse.com/#feat=sql-storage

标签: sqlite cordova ionic-framework ionic2


【解决方案1】:

您无法通过 Cordova Web 浏览器打开数据库。 您可以使用 Visual Studio 提供的Emulator for Android

这样数据库就可以访问了。

【讨论】:

    【解决方案2】:

    看来您必须使用模拟才能在 SQlite 中使用浏览器环境。我也会试试这个:https://medium.com/@tintin301/ionic-sqlite-storage-setting-up-for-browser-development-and-testing-67c0f17fc7af

    有些人对此提出警告,所以我会推荐这种其他方法: https://forum.ionicframework.com/t/ionic-native-sqlite-issue/87416/18

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 2011-10-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多