使用PhoneGap在Android应用中使用dojox.mobile.TextBox发出问题

时间:2013-06-04 14:03:41

标签: android dojo cordova

我在Android应用中使用小工具dojox.mobile.TextBox时遇到问题。 这是简单的html文件:

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="dojo/dojox/mobile/themes/custom/custom.css" type="text/css" media="screen" title="no title" charset="utf-8">

<script type="text/javascript" charset="utf-8" src="js/cordova-2.6.0.js"></script>
<script type="text/javascript" charset="utf-8">
        function onLoad() {
            document.addEventListener("deviceready", onDeviceReady, false);
        }

        // Cordova is loaded and it is now safe to make calls Cordova methods
        //
        function onDeviceReady() {

        }
    </script>
</head>
<body onload="onLoad();">

    <div>
        <input data-dojo-type="dojox.mobile.TextBox" placeHolder="Enter LAST name" />
    </div>

    <script type="text/javascript" charset="UTF-8" src="dojo/dojo/dojo.js" ></script>
    <script type="text/javascript" charset="UTF-8">
        // Load the widget parser and mobile base
        require([
        "dojox/mobile/parser",
        "dojox/mobile/deviceTheme",
        "dojox/mobile/compat",
        "dojox/mobile",
        "dojox/mobile/TextBox"
        ], function(parser, deviceTheme) {
            // Parse the page for widgets!
            parser.parse();
            });

    </script>
</body>
</html>

这是我得到的错误:

06-04 15:22:52.304: E/Web Console(28791): Uncaught Error: declare dojox.mobile.TextBox: mixin #1 is unknown. Did you use dojo.require to pull it in? at file:///android_asset/www/dojo/dojo/dojo.js:15

我也尝试过dojox.mobile.app.TextBox,但后来我得到了:

06-04 15:46:16.192: E/Web Console(29566): Uncaught TypeError: Cannot read property 'dynamic' of undefined at file:///android_asset/www/dojo/dojo/dojo.js:15

我确定我有最后一个版本的dojo。 如果有人有答案,那对我真的很有帮助。 感谢。

1 个答案:

答案 0 :(得分:0)

我会先动一下:

<script type="text/javascript" charset="UTF-8" src="dojo/dojo/dojo.js" ></script>
<script type="text/javascript" charset="UTF-8">
    // Load the widget parser and mobile base
    require([
    "dojox/mobile/parser",
    "dojox/mobile/deviceTheme",
    "dojox/mobile/compat",
    "dojox/mobile",
    "dojox/mobile/TextBox"
    ], function(parser, deviceTheme) {
        // Parse the page for widgets!
        parser.parse();
        });

进入head标签区域并添加“dojo / domReady!”对你dojo要求阻止。您应该在头部添加另一个东西来正确配置dojo:

<script>dojoConfig = {
async: true,
parseOnLoad: true
}
</script>

你应该研究这里的所有例子:
http://download.dojotoolkit.org/release-1.9.0/dojo-release-1.9.0/dojox/mobile/tests/