SVGPointList

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

SVGPointList 介面表示一個 DOMPoint 物件列表。

SVGPointList 可以被指定為只讀,這意味著嘗試修改該物件將導致丟擲異常。

例項屬性

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

瀏覽器相容性