我尝试通过cordova-sqlite-storage
安装此插件https://github.com/xpbrew/cordova-sqlite-storage。我使用framework7。
看起来插件已安装,因为再次输入安装命令时,我会看到
C:\Users\User\Desktop\pj>cordova plugin add cordova-sqlite-storage
Plugin "cordova-sqlite-storage" already installed on android.
Plugin "cordova-sqlite-storage" already installed on browser.
Adding cordova-sqlite-storage to package.json
这是我使用sqlite的代码: route.js
routes = [
{
path: '/',
url: './index.html',
},
{
path: '/drive/',
url: './pages/drive.html',
on: {
pageInit: function (e, page) {
//db start
window.sqlitePlugin.echoTest(function() {
console.log('ECHO test OK');
alert('ECHO test OK');
});
window.sqlitePlugin.selfTest(function() {
console.log('SELF test OK');
alert('SELF test OK');
});
[...]
在控制台中,我看到了
TypeError: window.sqlitePlugin is undefined
答案 0 :(得分:0)
将此添加到您的index.html, 但在任何脚本之前:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="plugins/cordova-sqlite-storage/www/SQLitePlugin.js"></script>
<!-- your other scripts here -->