桌面网络浏览器上的电容器-sqlite:类型错误:x 不是数据库打开时的函数

问题描述 投票:0回答:1

最小可重现示例:

https://github.com/folsze/capacitor-v6-sqlite-x-is-not-a-function

导致问题的确切更改的最小提交:

https://github.com/folsze/capacitor-v6-sqlite-x-is-not-a-function/commit/8beedb051dd5b3670548db975ff8b06a399aea58

电容器社区 sqlite:类型错误:升级到电容器版本 6 后,x 不是启动时的函数

当我启动我的角离子电容器社区 sqlite 应用程序时,我得到:

ERROR TypeError: x is not a function

在浏览器控制台中。

这一切仅发生在桌面浏览器上🖥️。在本机 ios/android (🍏/👾) 上,一切都可以正常工作。浏览器使用

sql-wasm.wasm
afaik,因此 sql.js,一个内存数据库,请在此处阅读更多内容:

https://github.com/capacitor-community/sqlite/blob/master/docs/Web-Usage.md

重现该行为的步骤:

  1. 克隆此存储库:https://github.com/folsze/capacitor-v6-sqlite-x-is-not-a-function
  2. 使用 npm start 在桌面浏览器中启动应用程序
  3. 检查控制台,你会看到错误“TypeError: x is not a function”
  4. 预期行为:无错误

相关github问题:

https://github.com/capacitor-community/sqlite/issues/574

编辑: 在我的最小可重现示例中降级到 capv5 后,该错误也以某种方式发生,但不在我的主代码库 capv5 中:

https://github.com/folsze/capacitor-v6-sqlite-x-is-not-a-function/commit/4201f5156bdf47f0d6744c9f7cd29fd7ccf41a1a

很奇怪。

javascript angular sqlite ionic-framework capacitor
1个回答
0
投票

已解决此 github 问题:

https://github.com/capacitor-community/sqlite/issues/574#issuecomment-2269161964

您好,我刚刚找到了一种使用 Ionic v8 运行的方法。问题(至少在我的情况下)是 sql.js 的版本。使用可战斗版本的sql.js(1.10.3)并复制1.10.3版本的sql-wasm.wasm 这是package.json的更新版本

{
  "private": true,
  "version": "0.0.1",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build",
    "preview": "vite preview",
    "test:e2e": "cypress run",
    "test:unit": "vitest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@capacitor-community/sqlite": "^6.0.1",
    "@capacitor/android": "6.1.1",
    "@capacitor/app": "6.0.0",
   
    "@ionic/vue": "^8.0.0",
    "@ionic/vue-router": "^8.0.0",
    "@types/geojson": "^7946.0.14",
    "@types/leaflet": "^1.9.12",
    "ionicons": "^7.0.0",
    "jeep-sqlite": "^2.7.2",
    "sql.js": "1.10.3", // use specific version
  }
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.