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