Javascript 如何在dojo.connect中传递元素

Javascript 如何在dojo.connect中传递元素,javascript,dojo,event-handling,thumbnails,mouseover,Javascript,Dojo,Event Handling,Thumbnails,Mouseover,我正在dojo中创建一个小部件,用于放大鼠标上方的缩略图 小部件将mouseover事件与构造函数中的所有缩略图绑定,如下所示: dojo.connect(imgTag, "mouseover", this, "_showImgPreview"); 在_showImgPreview()中,我需要发生鼠标悬停事件的图像。通过以上操作,我只得到了事件,而不是图像 如何获取在_showImgPreview()中发生的事件的缩略图 我知道我可以这样做,但我很想知道如何使用上述方法 var self =

我正在dojo中创建一个小部件,用于放大鼠标上方的缩略图

小部件将mouseover事件与构造函数中的所有缩略图绑定,如下所示:

dojo.connect(imgTag, "mouseover", this, "_showImgPreview");
在_showImgPreview()中,我需要发生鼠标悬停事件的图像。通过以上操作,我只得到了事件,而不是图像

如何获取在_showImgPreview()中发生的事件的缩略图

我知道我可以这样做,但我很想知道如何使用上述方法

var self = this;
dojo.connect(imgTag, "mouseover", function(e){
   self._showImgPreview(e, this);
});

提前谢谢你

e.目标将是imgTag

如果您在扩展小部件的类中,则可以使用

this.connect(imgTag, "mouseover", "_showImgPreview");
dojo.connect(imgTag, "mouseover", dojo.hitch(this, this._showImgPreview));
如果你不是,你可以使用

this.connect(imgTag, "mouseover", "_showImgPreview");
dojo.connect(imgTag, "mouseover", dojo.hitch(this, this._showImgPreview));

注意:
dojo/connect
已被弃用,取而代之的是
dojo/on

我在类中。如何在_showImgPreview方法中获得imgTag?e.target[编辑答案以添加此内容]