SVGPointList: length 属性

Baseline 已广泛支持

此功能已经成熟,并可在许多设备和浏览器版本上使用。自 ⁨2020 年 3 月⁩起,它已在各浏览器中推出。

SVGPointList 接口的只读属性 length 返回列表中的项目数。

列表中项目的数量。

示例

以下示例显示了一个包含五个坐标对的 <polyline> 的 SVG。length 属性返回 5

html
<svg id="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
let example = document.getElementById("example");
console.log(example.points.length); // 5

规范

规范
Scalable Vector Graphics (SVG) 2
# __svg__SVGNameList__length

浏览器兼容性