【发布时间】:2016-10-03 11:34:52
【问题描述】:
我在 Typescript 中有一个类函数,它向谷歌地图添加一个圆圈并添加一个事件侦听器。在该侦听器中,我想引用this,分配我要添加侦听器的对象。 See this 作为在纯 JS 中如何工作的参考
不幸的是,Typescript 阻止我引用正确的 this,我该如何解决这个(问题,而不是 this)?
public drawGeoFence(/* params removed */) : void {
google.maps.event.addListener(circle, "mouseover", (event) => {
this.showGeofenceInfoWindow(map, geofence, this); // <<- this!
});
}
【问题讨论】:
标签: javascript google-maps typescript