繁体   English   中英

灰烬这在组件的组件中未定义

[英]Ember this is undefined in component's component

我正在使用Ember 2.18。

我有一个叫做map的组件,在这个组件中我正在使用插件ember-cli-g-maps。 对于这个组件,我传递了一个圆数组。

这是模板:

        {{g-maps
        name='geo-push-map'
        lat=location.lat
        lng=location.lon
        zoom=mapConfig.zoom
        mapType=mapConfig.mapTypeId
        disableDefaultUI=mapConfig.disableDefaultUI
        showZoomControl=mapConfig.zoomControl
        showScaleControl=mapConfig.scaleControl
        circles=circles
        }}

这是我的圈子数组的外观:

circles: A([
  {
    id: 'my-circle',
    lat: 45,
    lng: 15,
    radius: 2000,
    click(event, circle) {},
    rightclick(event, circle) {},
    dblclick(event, circle) {},
    mouseover(event, circle) {},
    mouseout(event, circle) {},
    mouseup(event, circle) {},
    mousedown(event, circle) {},
    mousemove(event, circle) {},
    drag(e, circle) {},
    dragstart(e, circle) {},
    dragend(e, circle) {},
    radius_changed(circle) {},
    center_changed(circle) {},
    clickable: true,
    draggable: true,
    editable: true,
    fillColor: '#009dd4',
    fillOpacity: 0.3,
    strokeColor: '#005d7d',
    strokeOpacity: 0.3,
    strokePosition: google.maps.StrokePosition.CENTER,
    strokeWeight: 3,
    visible: true,
    zIndex: 999,
  },
]),

现在,我希望能够在触发圆形事件时对地图组件内的属性进行突变。 我这样尝试过:

...
radius_changed(circle) {
 set(this, 'myRadius', circle.radius);
},
...

但是问题是,它告诉我this是不确定的。 我怀疑这是因为它不在圈子范围内。 有其他方法吗? 当然,我阅读了插件的文档以及相关问题,但找不到解决方法。

我通过使用支持将动作传递到圆形事件ember-google-maps的其他插件解决了该问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM