2

我只是想做一些基本的dojo和dijit工作。我似乎无法让新的 require() 函数在 1.7 中正常工作。出于某种原因,我的代码将错误记录到控制台,并且未解析小部件。这是代码:

<html>
    <head>
        <title>Fun with Button Clicking!</title>


        <link rel="stylesheet" type="text/css" href="../dojo/dojo/dojo-release-1.7.2-src/dojo/dojo.css" />
        <link rel="stylesheet" type="text/css" href="../dojo/dojo-release-1.7.2-src/dijit/themes/tundra/tundra.css" />

        <script>
        // Instead of using data-dojo-config, we’re creating a dojoConfig object
        // *before* we load dojo.js; they’re functionally identical.
        var dojoConfig = {
            async: true,
            parseOnLoad: true

        };
    </script>
    <script type="text/javascript" data-dojo-config="async: true" src="../dojo/dojo-release-1.7.2-src/dojo/dojo.js" ></script>

        <script type="text/javascript">
        require(["dojo/parser", "dijit/form/TextBox",  "dijit/form/Button", "dijit/form/NumberSpinner"], function(parser, textBox, button, spinner) {
            dojo.connect(dojo.byId("foo"), "onclick", function(evt) {
                console.log("connect fired for DOM Node onclick");
            });

            dojo.connect(dijit.byId("foo"), "onclick", function(evt) {
                console.log("connect fired for dijit onclick");    //never!
            });

            dojo.connect(dijit.byId("foo"), "onClick", function(evt) {
                console.log("connect fired for dijit onClick");
            });
        }); 
        </script>
    <head>
    <body class="tundra">

        <label>Spinner</label>
        <input data-dojo-type="dijit.form.NumberSpinner" name="spinna" constraints="{min:0,max:100}" value=100 />

        <button id="foo" data-dojo-type="dijit.form.Button" onclick="foo">click me
            <script type="dojo/method" event="onClick" args="evt">
                console.log("Button fired onClick");
            </script>
        </button>
    </body>
</html>

我在 firebug 中多次看到以下错误:

Error: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "file:///D:/dev/demo/dojo/dojo-release-1.7.2-src/dojo/_base/xhr.js Line: 735"]
()Deferred.js (line 295)
(undefined=""GET"", undefined="[object Object]")xhr.js (line 738)
lates/TextBox.html",false,(undefined="function (text) {theCac...}delete pending[url];})")text.js (line 17)
",(undefined="function (a1", undefined=" a2", undefined=" a3) {return contextRequire(a1", undefined=" a2", undefined=" a3", undefined=" module", undefined=" result);})", undefined="(function (def) {module...ule);checkComplete();})")text.js (line 92)
(undefined="[object Object]")dojo.js (line 1216)
(undefined="[object Object]")dojo.js (line 1038)
id]) {injectPlugin()dojo.js (line 93)
undefined = "modules[mid] = pluginRe...oPluginResource.mid];})"
(undefined="[object Object]")dojo.js (line 1030)
(undefined="[object Object]")dojo.js (line 1072)
(undefined="[object Object]")dojo.js (line 1132)
()dojo.js (line 1154)
()dojo.js (line 1323)
(undefined="[object Event]")

有谁知道这是怎么一回事?

4

1 回答 1

2

我不相信 Dojo 支持从文件系统加载。此错误确实提到了可能对您有用的解决方法。

http://bugs.dojotoolkit.org/ticket/12104

于 2012-04-11T18:38:21.037 回答