带有phonegap的dojo mobile无法正常工作

时间:2013-05-09 20:30:23

标签: html5 cordova dojo

我在Eclipse中使用phonegap和dojo开始编写应用程序。 Phonegap,没有dojo在Android模拟器上正常工作,在chrome中使用ripple插件。问题是我将dojo添加到项目中。我使用phonegap 2.7.0dojo 1.9.0。 我正在使用:http://www.ibm.com/developerworks/web/library/wa-mobappdev1/教程来设置它。

我如何设置dojo:

enter image description here

index.html文件:

<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>PhoneGap</title> 
        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <link rel="stylesheet" href="libs/dojo/dojox/mobile/themes/android/android.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
        <script type="text/javascript" src="libs/dojo/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
        <script type="text/javascript" charset="utf-8" src="cordova-2.7.0.js"></script> 
        <script type="text/javascript" charset="UTF-8" src="funkcja.js"></script>
        <script type="text/javascript">
          dojo.require("dojox.mobile.parser");
          dojo.require("dojox.mobile");
          dojo.require("dojox.mobile.app");
          dojo.require("dojox.mobile.Button");
        </script>
    </head> 
    <body> 
        <div dojoType="dojox.mobile.View" id="site" selected="true">
            <h1 dojoType="dojox.mobile.Heading">Index</h1>
            <div>
                <input dojoType="dojox.mobile.Button" type="button" id="submit" name="submit" value="Button" onclick="loguj()"/> 
            </div>  
        </div> 
    </body> 
</html>

在模拟器中,我得到一个空白屏幕。

在使用ripple的chrome中我只得到没有dojo脚本的html。脚本包括在内。在控制台中我收到错误:

Console was cleared ripple.js:37
Ripple :: Environment Warming Up (Tea. Earl Gray. Hot.) ripple.js:37
Uncaught SyntaxError: Unexpected token u Insertion.js:1
GET http://localhost/config.xml 404 (Not Found) ripple.js:50
cordova :: Initialization Finished (Make it so.) ripple.js:37
GET http://localhost/libs/dojo/dojo/fx/Toggler.js 404 (Not Found) ripple.js:50
Error {src: "dojoLoader", info: "xhrFailed"} dojo.js:15
GET http://localhost/cordova_plugins.json 404 (Not Found) ripple.js:50
Uncaught SyntaxError: Unexpected token < cordova-2.7.0.js:6816
GET http://localhost/libs/dojo/dojo/resources/blank.gif 404 (Not Found) app.js:15
deviceready has not fired after 5 seconds. cordova-2.7.0.js:6672
Channel not fired: onPluginsReady cordova-2.7.0.js:6665
Channel not fired: onCordovaReady cordova-2.7.0.js:6665
Channel not fired: onCordovaConnectionReady cordova-2.7.0.js:6665
deviceready has not fired after 5 seconds. cordova-2.7.0.js:6672
Channel not fired: onPluginsReady cordova-2.7.0.js:6665
Channel not fired: onCordovaReady cordova-2.7.0.js:6665
Channel not fired: onCordovaConnectionReady cordova-2.7.0.js:6665

3 个答案:

答案 0 :(得分:0)

Dojo尝试加载他的js文件,但不能。我认为这个答案对你也有用:

PhoneGap / Cordova 1.6 and dojo 1.7.2 AMD works from web, not from local?

  

将dojo.js的djConfig设置为djConfig =“async:false,parseOnLoad:true”    AND 在dojo.js之前加载cordova.js!

如果它不起作用&amp;你想开始开发,尝试从网上使用dojo.js.

答案 1 :(得分:0)

只需在cordova_plugins.json内创建一个www文件,其中包含{}

或者,您可以从6395->6415注释掉cordova-2.7.0.js行。

答案 2 :(得分:0)

我在IBM Website上遵循相同的教程,但也没有用。

要使其发挥作用,我必须执行以下操作:

  1. 删除djConfig="parseOnLoad:true"
  2. 替换

    dojo.require( “dojox.mobile.parser”); dojo.require( “dojox.mobile”); dojo.require( “dojox.mobile.app”); dojo.require( “dojox.mobile.Button”);

  3. with:

    require(["dojox/mobile/parser", "dojox/mobile", "dojox/mobile/app", "dojox/mobile/Button", "dojo/domReady!"],
        function(parser) {
            parser.parse();
        }
    );