好的,以下工作,但我必须相信有更好的方法。您可以通过移除某物并将其添加回来将其移动到前面。但是,删除它会删除 mouse* 侦听器,因此我必须将侦听器向上移动一个档次,就像这样(这是在具有 drawComponent 属性的组件内部(此时是“我”)。
var pathout = function(line,target,opts) {
line.setAttributes({ stroke: "blue", "stroke-width": 2 }, true );
line.on('mouseover',pathover, this,opts);
};
var pathover = function(line,target,opts) {
me.drawComponent.surface.remove(line,true);
me.drawComponent.surface.add( line ).show(true);
line.setAttributes({ stroke: "red", "stroke-width": 4}, true );
line.on('mouseout',pathout,this,opts);
};
this.paths[pathName] = {
type: "path",
path: "M" + path.join(" L"),
stroke: next_color,
"stroke-width": 2,
listeners: {
mouseover: pathover,
mouseout: pathout,
scope: this
}
};