SVGLength: valueInSpecifiedUnits 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

SVGLength 接口的 valueInSpecifiedUnits 属性表示一个浮点数值,其单位由 unitType 指定。

设置此属性将自动更新 valuevalueAsString 以反映此设置。

长度的数值因子,以浮点数形式表示。

示例

js
// Get an SVGLength object
const svg = document.querySelector("svg");
const length = svg.createSVGLength();

// Set the value of the length
length.value = 10;
console.log(length.valueInSpecifiedUnits); // Output: 10

// Update the numeric factor of the length
length.valueInSpecifiedUnits = 20;
console.log(length.valueInSpecifiedUnits); // Output: 20

规范

规范
Scalable Vector Graphics (SVG) 2
# __svg__SVGLength__valueInSpecifiedUnits

浏览器兼容性

另见