Sass Introspection 函數
Sass Introspection 函數比較少用於構建樣式表,一般用於代碼的調試上。
下表列出了 Sass 的 Introspection 函數:
函數 | 描述 & 實例 |
---|---|
call(function, arguments...) | 函數的動態調用,即調用函數 function 參數為 arguments,並返回結果。 |
content-exists() | 查看當前的混入是否傳遞 @content 塊。 |
feature-exists(feature) | 檢查當前的 Sass 實現是否支持該特性。 實例: feature-exists("at-error"); 結果: true |
function-exists(functionname) | 檢測指定的函數是否存在 實例: function-exists("nonsense") 結果: false |
get-function(functionname, css: false) | 返回指定函數。如果 css 為 true,則返回純 CSS 函數。 |
global-variable-exists(variablename) | 檢測某個全局變數是否定義。 實例: variable-exists(a) 結果: true |
inspect(value) | 返回一個字串的表示形式,value 是一個 sass 運算式。 |
mixin-exists(mixinname) | 檢測指定混入 (mixinname) 是否存在。 實例: mixin-exists("important-text") 結果: true |
type-of(value) | 返回值類型。返回值可以是 number, string, color, list,
map, bool, null, function, arglist。 實例: type-of(15px) 結果: number type-of(#ff0000) 結果: color |
unit(number) | 返回傳入數字的單位(或複合單位)。 實例: unit(15px) 結果: px |
unitless(number) | 返回一個布爾值,判斷傳入的數字是否帶有單位。 實例: unitless(15px) 結果: false unitless(15) 結果: true |
variable-exists(variablename) | 判斷變數是否在當前的作用域下。 實例: variable-exists(b) 結果: true |