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

浏览器兼容性

另见