2010-11-12 46 views
1

大家好我试图从dojo库中使用dijit并尝试使用日历组件。我遵循了在线文档中的代码,但它似乎不起作用。下面是我使用的代码:Dijit不工作

<html> 

<head> 
    <link rel="stylesheet" type="text/css" href="dijit/themes/claro/claro.css" 
    /> 
    <style type="text/css"> 
     body, html { font-family:helvetica,arial,sans-serif; font-size:90%; } 
    </style> 
    <style type="text/css"> 
     .claro table.dijitCalendarContainer { margin: 25px auto; } #formatted 
     { text-align: center; } 
    </style> 
</head> 

<body class=" claro "> 
    <div dojoType="dijit._Calendar" onChange="dojo.byId('formatted').innerHTML=dojo.date.locale.format(arguments[0], {formatLength: 'full', selector:'date'})"> 
    </div> 
    <p id="formatted"> 
    </p> 
</body> 
<script type="text/javascript" src="js/dojo.js" djConfig="parseOnLoad: true"> 
</script> 
<script type="text/javascript"> 
    dojo.require("dijit.dijit"); // loads the optimized dijit layer 
    dojo.require("dijit._Calendar"); 
</script> 
</html> 

使用Firebug它显示了以下错误:

Could not load 'dijit._Calendar'; last tried '../dijit/_Calendar.js'

请任何人都可以帮助我在此。我真的想做这个工作。 在此先感谢。

回答

1

你的树看起来已经改变了,或者至少你从标准发布版中重新定位了dojo.js的副本。你应该包括dojo作为“dojo/dojo.js”然后它将使用该引用来查找树中的相对URL,如../dijit/_Calendar.js

+0

我试过这个但仍然无法工作。我在控制台中得到以下错误: 未能加载dojo /../ dijit/form/_FormWidget.js错误:错误:无法加载'dojo.window';最后试过'./window.js' – 2010-11-13 06:07:28

+0

这些路径是否有效?你应该有一个dijit目录作为dojo的同伴,并且dojo/window.js和dijit/form/_FormWidget.js应该存在于树中...你的某些树可能缺失,或者可能是脚本标记中的初始路径还是不对?你可能想检查404的萤火虫网面板应该给你整个路径。将它与您的文件系统进行匹配。 – peller 2010-11-14 15:52:56