尝试从数组中绘制一些圆,它仅绘制最后一个圆。
但是,当我尝试consle.log
数组时,它将拆分所有坐标。
JS
for (var i = 0; i < points.length; ++i) {
circle.setAttribute('cx', points[i]["x"]);
circle.setAttribute('cy', points[i]["y"]);
circle.setAttribute('stroke', 'red');
circle.setAttribute('stroke-width', 5);
circle.setAttribute('r', 5);
circle.setAttribute('fill', 'green');
circle.setAttribute('fill-opacity',0);
circle.setAttribute('id',points[i]["id"]);
circle.addEventListener('contextmenu', function(event) {
circle.remove(circle.id);
event.preventDefault();
});
console.log(points[i]);
customSvg.appendChild(circle);
}