SVGPointList: getItem() 方法
SVGPointList 接口的 getItem() 方法可以根据指定的索引从列表中获取一个项。
语法
js
getItem(index)
参数
index-
要返回的项的索引。
返回值
一个 DOMPoint 对象。
异常
IndexSizeErrorDOMException-
如果传入的索引大于列表中的项数,则会抛出此异常。
示例
下面的示例展示了一个包含带有五个坐标对的 <polyline> 元素的 SVG。索引为 0 的 DOMPoint。
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
const example = document.getElementById("example");
console.log(example.points.getItem(0));
规范
| 规范 |
|---|
| Scalable Vector Graphics (SVG) 2 # __svg__SVGNameList__getItem |
浏览器兼容性
加载中…