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

瀏覽器相容性

另見