How would I get options from object?

时间:2019-02-18 18:39:36

标签: javascript jquery leaflet

This is the structure:

e {options: {…}, _latlng: M, _radius: 10, _initHooksCalled: true}
options:
id: "https://example.com/travel/weekend-a-barcelona/"
__proto__: Object
__parent: e {options: {…}, _latlng: M, _group: e, _zoom: 6, _markers: Array(2), …}
_events: {click: Array(1), dragstart: Array(1), move: Array(1), dragend: Array(1)}
_initHooksCalled: true
_latlng: M {lat: 41.39483307195536, lng: 2.148767850000013}
_leaflet_id: 495
_radius: 10
__proto__: e

I need to get the link id: "https://example.com/travel/weekend-a-barcelona/"

I tried

 circle.on('click', function (e) {
   var circleLink = e.target.options();
   alert(circleLink);

But I get Uncaught TypeError: e.target.options is not a function

1 个答案:

答案 0 :(得分:0)

您可以访问如下所示的嵌套对象。基本上,您是使用e.options获取选项的值,然后才能获取链接,您必须获取选项的值(我们之前发现的值为e.options)并添加{{1} } 到最后。您最终得到.id

e.options.id