例項屬性
SVGPointList.length只讀-
返回列表中點的數量。
SVGPointList.numberOfItems只讀-
返回列表中點的數量。
例項方法
SVGPointList.clear()-
移除列表中的所有項。
SVGPointList.initialize()-
首先移除列表中的所有項,然後向列表中新增單個值。
SVGPointList.getItem()-
獲取列表中指定位置的項。
SVGPointList.insertItemBefore()-
在指定位置將元素插入列表。
SVGPointList.replaceItem()-
用新項替換列表中的一項。
SVGPointList.removeItem()-
從列表中移除一項。
SVGPointList.appendItem()-
將一項新增到列表末尾。
示例
以下示例顯示了一個包含具有五個座標對的 <polyline> 的 SVG。points 屬性返回一個 SVGPointList。
html
<svg viewBox="-10 -10 120 120" xmlns="http://www.w3.org/2000/svg">
<polyline
id="example"
stroke="black"
fill="none"
points="50,0 21,90 98,35 2,35 79,90" />
</svg>
js
const example = document.getElementById("example");
console.log(example.points); // An SVGPointList
規範
| 規範 |
|---|
| Scalable Vector Graphics (SVG) 2 # 介面SVGPointList |
瀏覽器相容性
載入中…