0

我在我的 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

我确定我有最新版本的道场。如果有人有答案,那真的会帮助我。谢谢。

4

1 回答 1

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();
        });

进入头部标签区域并添加“dojo/domReady!” 对你道场要求块。您可能应该在头部添加另一件事来正确配置 dojo:

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

您应该研究位于此处的所有示例:http:
//download.dojotoolkit.org/release-1.9.0/dojo-release-1.9.0/dojox/mobile/tests/

于 2013-06-04T15:13:58.883 回答