gpt4 book ai didi

javascript - 如何在迭代循环时传递真实值?

转载 作者:行者123 更新时间:2023-11-30 15:53:38 26 4
gpt4 key购买 nike

<分区>

我觉得问题很明确了。这是我的代码:

 // Add markers for each spot
for(var spot of spots) {

var spotId: number = +spot.id;
console.log(spotId);

// Add marker for current spot
L.marker([spot.latitude, spot.longitude], {icon: this.mapService.getSchoolIcon() })
.addTo(this.map)
.on('click', () => console.log('CLICKED: ' + spotId) );
}

如果我单击所有引脚,这是控制台中的输出:

1
2
3
4
CLICKED: 4
CLICKED: 4
CLICKED: 4
CLICKED: 4

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com