javascript - Jeep-sqlite 加载程序未在网络中运行

标签 javascript sqlite browser vite

我用 Vite Vue Ionic capacitor 5 构建了一个应用程序(最新版本)和 SQLite。我尝试使用 @capacitor-community/sqlite 实现包。在移动模拟器上一切运行良好,但在浏览器中找不到 jeep-sqlite.entry.js:

enter image description here

初始连接:

     state() {
return {
  platform: Capacitor.getPlatform(),
  apiCon: null,
  db: null,
  dbdriver: new SQLiteConnection(CapacitorSQLite),
  network: {
    connected: false,
    connectionType: "none",
  },
};
}

applyPolyfills().then(() => {
        jeepSqlite(window);
      });
      console.log("1");

      // Create the 'jeep-sqlite' Stencil component

      const jeepEl = await document.createElement("jeep-sqlite");
      console.log("2");

      await document.body.appendChild(jeepEl);
      console.log("3");

      await customElements.whenDefined("jeep-sqlite");
      console.log("4");

      // Initialize the Web store

      await this.state.dbdriver.initWebStore();
      console.log("5");

运行步骤 1 至 4。如何解决这个问题?

最佳答案

我在 Vite React ionic 电容器设置中遇到了同样的问题。您必须从 vite.config.ts 中的优化 deps 中排除 jeep-sqlite 加载程序:

export default defineConfig({
  optimizeDeps: {
    exclude: ['jeep-sqlite/loader']
  }
});

关于javascript - Jeep-sqlite 加载程序未在网络中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76631171/

相关文章:

javascript - Cordova 在后台运行 JavaScript 函数

android - 数据库不是在android中创建的

silverlight - 如何更改 Silverlight for Windows Phone 上 Web 浏览器上的 ComboBox "selectedIndex"?

C# Web浏览器点击Javascript按钮

javascript - 如何创建从一个 ng-view 到另一个 ng-view 的缩放动画?

javascript - Carbone JS 与 React JS 的结合使用

sqlite - CoolStorage 字段不等于过滤器

javascript - 打印 HTML 页面

javascript - 编写一个更新/保存的 Mongoose 方法?

sqlite - 通过将 SQLite 表分成两部分并与外键链接来重构 SQLite 表