我需要在菜单栏项目中显示图标及其在dijit菜单栏中的标签。根据文档,我们可以通过在配置中指定iconClass属性来设置图标。以下是代码,但图标仍未显示。它是道场中的错误吗?
var form1 = {};
require(["dojo/ready", "dijit/MenuBar", "dijit/PopupMenuBarItem"], function (ready, MenuBar, PopupMenuBarItem) {
ready(function () {
form1.menu_bar = new MenuBar({}, "menu");
form1.item1 = new PopupMenuBarItem({
label: "Cut",
iconClass: "dijitEditorIcon dijitEditorIconCut"
}, "item1");
form1.menu_bar.addChild(form1.item1);
form1.menu_bar.startup();
});
});
JS-FIDDLE: http://jsfiddle.net/X2xjt/
答案 0 :(得分:0)
文档确实是正确的。如果将PopupMenuBarItem换成dijit/MenuItem
,您将看到该图标在菜单项旁边按预期呈现。 PopupMenuBarItem要求在创建时指定popup
属性(请参阅reference docs),这会导致在调用form1.menu_bar.startup()
时抛出错误。
var form1 = {};
require(["dojo/ready", "dijit/MenuBar", "dijit/MenuItem"], function (ready, MenuBar, MenuItem) {
ready(function () {
form1.menu_bar = new MenuBar({}, "menu");
form1.item1 = new MenuItem({
label: "Cut",
iconClass: "dijitEditorIcon dijitEditorIconCut"
}, "item1");
form1.menu_bar.addChild(form1.item1);
form1.menu_bar.startup();
});
});
答案 1 :(得分:-1)
找到答案。使用dijit/PopupMenubarItem
无法执行此操作。这就是为什么http://dojotoolkit.org/reference-guide/1.9/dijit/MenuBar.html#icons