我正在尝试制作菜单,因为某种原因我甚至无法运行此示例代码!关于firbug的错误是:
Could not load class "dijit.DropDownMenu"
每个其他dojo菜单相关的类都在工作,我通过删除下面的部分代码来测试它,看看是否有其他东西没有渲染。
<div data-dojo-type="dijit.MenuBar" id="actionMenu">
<div data-dojo-type="dijit.PopupMenuBarItem">
<span>File</span>
<div data-dojo-type="dijit.DropDownMenu" id="fileMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('file 1');}">File #1</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('file 2');}">File #2</div>
</div>
</div>
<div data-dojo-type="dijit.PopupMenuBarItem">
<span>Edit</span>
<div data-dojo-type="dijit.DropDownMenu" id="editMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('edit 1');}">Edit #1</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('edit 2');}">Edit #2</div>
</div>
</div>
有谁可以指出为什么?我已经使用了以下的需求声明
dojo.require("dijit.MenuBar");
dojo.require("dijit.PopupMenuBarItem");
dojo.require("dijit.DropDownMenu");
dojo.require("dijit.MenuItem");
答案 0 :(得分:1)
您尚未提供有关如何获取库参考或版本的信息。因此,我认为它是googleapi,因为这是获得类似错误的唯一方法。
事实是,当你引用图书馆时,让我们说googleapi's它不起作用。我试过使用1.6而不是1.2。没运气。简单来说,对dojo库的引用不包含DropDownMenu定义。
解决方案是不使用googleapis :) 从下载页面下载Dojo的源代码版本,并使用对该构建的引用。它适用于版本1.7.2。或使用其他一些链接而不是谷歌的
希望这有帮助。
<html>
<head>
<link rel="stylesheet" type="text/css" href="dojo172/dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css" href="dojo172/dojo/resources/dojo.css" />
<script type="text/javascript">djConfig = { parseOnLoad:true, isDebug:true };</script>
<script type="text/javascript" src="dojo172/dojo/dojo.js"></script>
<script>
dojo.require("dijit.DropDownMenu");
dojo.require("dijit.MenuItem");
dojo.require("dijit.MenuSeparator");
dojo.require("dijit.PopupMenuItem");
dojo.require("dijit.MenuBar");
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.DropDownMenu" id="navMenu">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCut',
onClick:function(){alert('drama!')}">Drama</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCopy',
onClick:function(){alert('comedy!')}">Comedy</div>
<div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconPaste',
onClick:function(){alert('romance!')}">Romance</div>
<div data-dojo-type="dijit.MenuSeparator"></div>
<div data-dojo-type="dijit.PopupMenuItem">
<span>Action</span>
<div data-dojo-type="dijit.DropDownMenu" id="submenu2">
<div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('diehard!')}">Diehard</div>
<div data-dojo-type="dijit.MenuItem" onclick="alert('indiana!')">Indiana Jones</div>
</div>
</div>
</div>
</body>
</html>
答案 1 :(得分:0)
当你得到一个在Dojo中找不到的课时: