尝试使用Cordova-SQLitePlugin时出现SyntaxError

时间:2012-11-10 09:27:44

标签: javascript cordova phonegap-plugins

我正在尝试使用带有PhoneGap的预填充数据库,所以我在THIS文章的帮助下尝试THIS插件。这是我正在尝试运行的代码:< / p>

JS:

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

// Cordova is loaded and it is now safe to make calls Cordova methods
//
function onDeviceReady() {
    var db = window.sqlitePlugin.openDatabase(“test.db”, “1.0”, “testsstst”, 20000);

}

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>

我收到这些错误:

11-10 11:19:27.961: D/CordovaLog(9264): Uncaught SyntaxError: Unexpected token ILLEGAL
11-10 11:19:27.965: D/CordovaLog(9264): file:///android_asset/www/js/index.js: Line 8 : Uncaught SyntaxError: Unexpected token ILLEGAL
11-10 11:19:27.965: E/Web Console(9264): Uncaught SyntaxError: Unexpected token ILLEGAL at file:///android_asset/www/js/index.js:8
11-10 11:19:28.976: D/CordovaLog(9264): Uncaught ReferenceError: onLoad is not defined
11-10 11:19:28.976: D/CordovaLog(9264): file:///android_asset/www/index.html: Line 27 : Uncaught ReferenceError: onLoad is not defined
11-10 11:19:28.976: E/Web Console(9264): Uncaught ReferenceError: onLoad is not defined at file:///android_asset/www/index.html:27
11-10 11:19:28.996: D/Cordova(9264): onPageFinished(file:///android_asset/www/index.html)

任何帮助?

1 个答案:

答案 0 :(得分:0)

最有可能是你的报价:

var db = window.sqlitePlugin.openDatabase(“test.db”, “1.0”, “testsstst”, 20000);

VS

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