SVGAnimatedEnumeration: baseVal 屬性

Baseline 已廣泛支援

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

SVGAnimatedEnumeration 介面的 baseVal 屬性包含 SVG 列舉的初始值。

一個包含列舉初始值的整數

示例

考慮這個包含 <clipPath> 元素的片段:它的 clipPathUnits 屬性與一個 SVGAnimatedEnumeration 物件相關聯。

html
<svg viewBox="0 0 100 100" width="200" height="200">
  <clipPath id="clip1" clipPathUnits="userSpaceOnUse">
    <circle cx="50" cy="50" r="35" />
  </clipPath>

  <!-- Some reference rect to materialized to clip path -->
  <rect id="r1" x="0" y="0" width="45" height="45" />
</svg>

此片段獲取元素,並記錄 SVGClipPathElement.clipPathUnits 屬性的 baseVal

js
const clipPathElt = document.getElementById("clip1");
console.log(clipPathElt.clipPathUnits.baseVal); // Logs 1 that correspond to userSpaceOnUse

規範

規範
Scalable Vector Graphics (SVG) 2
# __svg__SVGAnimatedEnumeration__baseVal

瀏覽器相容性

另見