本文介绍了设置dijit.MenuItem的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一种情况,我们只在运行时知道菜单项的图标。我知道一个 diji.MenuItem iconClass 参数,但这没有什么帮助,除非我们动态添加CSS运行时的规则是 dojox.html.insertCssRule - 必须有更好的方法!



这里是一个例子我们正在努力:

  pMenu = new dijit.Menu({
targetNodeIds:[NEW_APP] ,
leftClickToOpen:true
});

pMenu.popupDelay = 100;

pMenu.addChild(new dijit.PopupMenuItem({
label:clocks,
iconSrc:image / clocks.png,
onClick:dojo。 hitch(core.editor,core.editor.createNewApp)
}));


解决方案

当然,有一个更好的方法,虽然不是很理想,如:




myMenuItem.iconNode.style.cssText =
background-image:url(...); width:16px,height:16px;


We have a case where we only know the icon for a menu item at runtime. I know there is a iconClass parameter for a diji.MenuItem, but this is of little help unless we dynamically add CSS rules at runtime with dojox.html.insertCssRule - there must be a better way!

Here is an example of what we are trying to do:

pMenu = new dijit.Menu({
    targetNodeIds: ["NEW_APP"],
    leftClickToOpen: true
});

pMenu.popupDelay = 100;

pMenu.addChild(new dijit.PopupMenuItem({
    label: "clocks",
    iconSrc: "image/clocks.png",
    onClick: dojo.hitch(core.editor, core.editor.createNewApp)
}));
解决方案

Sure, there's a better way although not ideal, something like:

myMenuItem.iconNode.style.cssText = "background-image: url(...); width: 16px, height: 16px";

这篇关于设置dijit.MenuItem的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 23:47