<script> 的加载失败,来源为“http://ajax.googleapis.com/ajax/libs/dojo/1.8.1/digit/form/FORM].js”

Loading failed for the <script> with source “http://ajax.googleapis.com/ajax/libs/dojo/1.8.1/digit/form/FORM].js”

/* 下面是我的代码 我正在尝试使用代码中的数字形式使用 require 添加按钮,但它显示加载失败 script.I 我只是在使用基本语法,但我不知道到底是什么谁能告诉我错了*/

<html>
    <head>
        <title> Intro to Dojo, part 1 </title>
        <style>
            .highlight {
                 background: yellow;
                font-weight: bold;
                font-size: 1.5em;
            }
        </style>
    </head>
<body> 
    <ul id="nav">
        <li> <a href="/">Home</a> </li>
        <li class="highlight"> <a href="/portfolio"> Portfolio </a> </li>
        <li> <a href="/about">Abou</a> </li>
        <li> <a href="/contact">Contact</a> </li>
    </ul>

    <p> This is a paragraph (albeit a very <em>short</em> paragraph). Also, <a href="http://google.com">here&#39;s a link</a>. </p>

    <script  type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js"></script>

    <script>dojo.create("p", { innerHTML: "Hi there!"}, dojo.body(), "first");

        dojo.create("h1", { innerHTML: "Heading"}, dojo.query("p")[0], "after");
        var h = dojo.query("p")[0],

            handle = dojo.connect(h, "onclick", function () {
                alert("learning Dojo");
                dojo.disconnect(handle);
            });

        var items = dojo.query("li");

        items.attr("innerHTML"); // [" <a href="/">Home</a>", " <a href="/portfolio">Portfolio</a>", " <a href="/about">About</a>", " <a href="/contact">Contact</a>"]

        items.attr({ className: "btn" });

        require(["digit/form/FORM]"],function(){
        var btn = new dijit.form.Button({ label: "Hello" });  
        dojo.place(btn.domNode, dojo.body());
        });

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

您将传递给 require 的库名称拼错了。首先,digit/form/FORM] 中的右方括号有错字。此外,dojo 工具包中没有名为 FORM 的模块,dojo 小部件库称为 dijit,而不是 digit。最后,您将要创建 dijit 库的按钮,因此实际上您可能想要导入 dijit/form/Button。这会导致这样的结果:

require(["dijit/form/Button"], function (Button) {
    var btn = new Button({
        label: "Hello"
    });
    dojo.place(btn.domNode, dojo.body());
});