声明在DOJO中未定义错误

时间:2013-09-18 07:19:19

标签: javascript dojo

我在使用FireBug打开我的应用程序时收到错误“Declare is not define error”。我正在使用DOJO框架,并希望开始编写代码。请帮我找到问题。

define(["dojo/_base/lang",
        ],

        function (lang){
        return declare ("app.Sample",{
            testM : function test(){
                alert('hi');
            }
        }       
        );
    }
);

<html>
<head>
    <link rel="stylesheet" href="src/dijit/themes/claro/claro.css" media="screen">
</head>
 <script>
    var dojoConfig = {baseUrl:"src" ,packages: [{ name: "dojo", 
        location: "dojo" },{ name: "dijit", location: "dijit" },{ name: "dojox", location: "dojox" },{ name: "app", location: "app"},], 
        parseOnLoad: true,  useXDomain:true, async: true, debugAtAllCosts: true};
</script>
<script src="src/dojo/dojo.js"></script>
    <body>
        <script type="text/javascript"> 
            require([
                'app/Sample']);
        </script>
    </body>
</html>

1 个答案:

答案 0 :(得分:2)

我发现了这个问题。我必须导入dojo/_base/declare。我的代码中缺少这个。