SVGCircleElement: r 屬性

Baseline 已廣泛支援

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

SVGCircleElement 介面的只讀屬性 r 反映了 <circle> 元素的 r 屬性,從而定義了圓的半徑。

如果未指定,則效果如同將值設定為 0

一個表示圓半徑的 SVGAnimatedLength 物件。

示例

SVG

html
<svg
  xmlns="http://www.w3.org/2000/svg"
  viewBox="0 0 100 100"
  width="200"
  height="200">
  <circle r="50" fill="gold" id="circle" />
</svg>

JavaScript

js
const circle = document.getElementById("circle");
console.log(circle.r);

規範

規範
Scalable Vector Graphics (SVG) 2
# __svg__SVGCircleElement__r

瀏覽器相容性

另見