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