我會動態(tài)地向路徑添加點這是我的代碼const cir1 = document.createElementNS('http://www.w3.org/2000/svg', 'circle');let path= document.getElementById('path9');this.getPath=path;let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');let pt = path.getPointAtLength('60');g.setAttribute('transform', `translate(${pt.x},${pt.y})`);g.appendChild(cir1)cir1.setAttribute('r', '3');cir1.setAttribute('fill', 'red');cir1.setAttribute('id','123');let svg =document.getElementById('Calque_1');svg.appendChild(g)實際上點被移動了,而不是在我無法弄清楚為什么的路徑上。
使用 getPointAtLength() 向路徑添加圓被移動
胡說叔叔
2021-09-04 15:06:35