數字
階層
- 數字
建構函式
建構函式 (constructor)
- new
Number (value: number, unit?: string): Number -
範例
new sass.types.Number(0.5); // == 0.5
new sass.types.Number(10, "px"); // == 10px
new sass.types.Number(10, "px*px"); // == 10px * 1px
new sass.types.Number(10, "px/s"); // == math.div(10px, 1s)
new sass.types.Number(10, "px*px/s*s"); // == 10px * math.div(math.div(1px, 1s), 1s)參數
-
value: number
數字的數值。
-
選用
unit: string若有傳入,則為數字的單位。
複雜單位可以表示為
<unit>*<unit>*.../<unit>*<unit>*...
,分子單位在/
的左側,分母單位在右側。 只有分子單位的數字可以省略/
和其後的單位,而只有分母單位的數字可以用/
前沒有單位來表示。
回傳 Number
-
方法
getUnit
- get
Unit (): string -
回傳此數字單位的字串表示。 複雜單位以 建構式 接受它們的相同格式回傳。
範例
// number is `10px`.
number.getUnit(); // "px"
// number is `math.div(10px, 1s)`.
number.getUnit(); // "px/s"回傳 string
Sass 的數字類型。