gpt4 book ai didi

PhoneGap : Uncaught TypeError cannot call method 'opendatabase' of undefined 中的 Cordova-SQLitePlugin

转载 作者:行者123 更新时间:2023-12-01 02:30:27 26 4
gpt4 key购买 nike

我正在尝试使用预先填充的数据库,但我不断收到此错误:

11-10 22:53:35.781: D/CordovaLog(20142): Uncaught TypeError: Cannot call method 'openDatabase' of undefined
11-10 22:53:35.781: D/CordovaLog(20142): file:///android_asset/www/js/index.js: Line 8 : Uncaught TypeError: Cannot call method 'openDatabase' of undefined
11-10 22:53:35.781: E/Web Console(20142): Uncaught TypeError: Cannot call method 'openDatabase' of undefined at file:///android_asset/www/js/index.js:8

这是代码:
HTML

<html>
<script type="text/javascript" src="js/index.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World</title>
</head>
<body onload="onLoad()">
<div class="app">
<h1>AAAA</h1>
</div>
<script type="text/javascript" src="cordova-2.2.0.js"></script>
</body>
</html>

JS:

function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase("test.db", "1.0", "testsstst", 20000);
}

为什么是这样?

最佳答案

您还应该在 HTML 中包含“SQLitePlugin.js”,如下所示:

<body>
...
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="SQLitePlugin.js"></script>
...
</body>

关于PhoneGap : Uncaught TypeError cannot call method 'opendatabase' of undefined 中的 Cordova-SQLitePlugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13326030/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com