sass:meta
- Dart Sass
- since 1.23.0
- LibSass
- ✗
- Ruby Sass
- ✗
Only Dart Sass currently supports loading built-in modules with @use
. Users
of other implementations must call functions using their global names instead.
混入混入 permalink
¥Mixins
meta.apply($mixin, $args...)
- Dart Sass
- since 1.69.0
- LibSass
- ✗
- Ruby Sass
- ✗
包括 $mixin
和 $args
。如果通过 @content
块,则会将其转发到 $mixin
。
¥Includes $mixin
with $args
. If this is passed a @content
block, it’s
forwarded to $mixin
.
$mixin
必须是 混入值,例如 meta.get-mixin()
返回的 混入值。
¥The $mixin
must be a mixin value, such as one returned by
meta.get-mixin()
.
SCSS Syntax
@use "sass:meta";
@use "sass:string";
/// Passes each element of $list to a separate invocation of $mixin.
@mixin apply-to-all($mixin, $list) {
@each $element in $list {
@include meta.apply($mixin, $element);
}
}
@mixin font-class($size) {
.font-#{$size} {
font-size: $size;
}
}
$sizes: [8px, 12px, 2rem];
@include apply-to-all(meta.get-mixin("font-class"), $sizes);
Sass Syntax
@use "sass:meta"
@use "sass:string"
/// Passes each element of $list to a separate invocation of $mixin.
@mixin apply-to-all($mixin, $list)
@each $element in $list
@include meta.apply($mixin, $element)
@mixin font-class($size)
.font-#{$size}
font-size: $size
$sizes: 8px, 12px 2rem
@include apply-to-all(meta.get-mixin("font-class"), $sizes)
CSS Output
.font-8px {
font-size: 8px;
}
.font-12px {
font-size: 12px;
}
.font-2rem {
font-size: 2rem;
}
meta.load-css($url, $with: null)
- Dart Sass
- since 1.23.0
- LibSass
- ✗
- Ruby Sass
- ✗
Only Dart Sass currently supports this mixin.
在 $url
处加载 模块 并包含其 CSS,就好像它是作为此 mixin 的内容编写的一样。$with
参数为模块提供 配置;如果它被传递,它必须是从变量名称(不带 $
)到要在加载的模块中使用的这些变量的值的映射。
¥Loads the module at $url
and includes its CSS as though it were written
as the contents of this mixin. The $with
parameter provides
configuration for the modules; if it’s passed, it must be a map from
variable names (without $
) to the values of those variables to use in the
loaded module.
如果 $url
是相对的,则它被解释为相对于包含 meta.load-css()
的文件。
¥If $url
is relative, it’s interpreted as relative to the file in which
meta.load-css()
is included.
像 @use
规则 一样:
¥Like the @use
rule:
-
这只会评估给定的模块一次,即使它以不同的方式加载了多次。
¥This will only evaluate the given module once, even if it’s loaded multiple times in different ways.
-
这无法为已加载的模块提供配置,无论它是否已加载配置。
¥This cannot provide configuration to a module that’s already been loaded, whether or not it was already loaded with configuration.
与 @use
规则 不同:
¥Unlike the @use
rule:
-
这不会使已加载模块中的任何成员在当前模块中可用。
¥This doesn’t make any members from the loaded module available in the current module.
-
这可以在样式表中的任何地方使用。它甚至可以嵌套在样式规则中以创建嵌套样式!
¥This can be used anywhere in a stylesheet. It can even be nested within style rules to create nested styles!
-
正在加载的模块 URL 可以来自变量并包含 插值法。
¥The module URL being loaded can come from a variable and include interpolation.
⚠️ Heads up!
The `$url` parameter should be a string containing a URL like you'd pass to
the `@use` rule. It shouldn't be a CSS `url()`!
SCSS Syntax
// dark-theme/_code.scss
$border-contrast: false !default;
code {
background-color: #6b717f;
color: #d2e1dd;
@if $border-contrast {
border-color: #dadbdf;
}
}
// style.scss
@use "sass:meta";
body.dark {
@include meta.load-css("dark-theme/code",
$with: ("border-contrast": true));
}
Sass Syntax
// dark-theme/_code.sass
$border-contrast: false !default
code
background-color: #6b717f
color: #d2e1dd
@if $border-contrast
border-color: #dadbdf
// style.sass
@use "sass:meta"
body.dark
$configuration: ("border-contrast": true)
@include meta.load-css("dark-theme/code", $with: $configuration)
CSS Output
body.dark code {
background-color: #6b717f;
color: #d2e1dd;
border-color: #dadbdf;
}
函数函数 permalink
¥Functions
meta.accepts-content($mixin) //=> boolean
- Dart Sass
- since 1.69.0
- LibSass
- ✗
- Ruby Sass
- ✗
返回给定的 混入值 是否可以接受 @content
块。
¥Returns whether the given mixin value can accept a @content
block.
如果 mixin 可以接受 @content
块,则返回 true,即使它并不总是这样做。
¥This returns true if it’s possible for the mixin to accept a @content
block, even if it doesn’t always do so.
meta.calc-args($calc) //=> list
- Dart Sass
- since 1.40.0
- LibSass
- ✗
- Ruby Sass
- ✗
返回给定 计算 的参数。
¥Returns the arguments for the given calculation.
如果参数是数字或嵌套计算,则以该类型返回。否则,它将作为不带引号的字符串返回。
¥If an argument is a number or a nested calculation, it’s returned as that type. Otherwise, it’s returned as an unquoted string.
SCSS Syntax
@use 'sass:meta';
@debug meta.calc-args(calc(100px + 10%)); // unquote("100px + 10%")
@debug meta.calc-args(clamp(50px, var(--width), 1000px)); // 50px, unquote("var(--width)"), 1000px
Sass Syntax
@use 'sass:meta'
@debug meta.calc-args(calc(100px + 10%)) // unquote("100px + 10%")
@debug meta.calc-args(clamp(50px, var(--width), 1000px)) // 50px, unquote("var(--width)"), 1000px
meta.calc-name($calc) //=> quoted string
- Dart Sass
- since 1.40.0
- LibSass
- ✗
- Ruby Sass
- ✗
返回给定 计算 的名称。
¥Returns the name of the given calculation.
SCSS Syntax
@use 'sass:meta';
@debug meta.calc-name(calc(100px + 10%)); // "calc"
@debug meta.calc-name(clamp(50px, var(--width), 1000px)); // "clamp"
Sass Syntax
@use 'sass:meta'
@debug meta.calc-name(calc(100px + 10%)) // "calc"
@debug meta.calc-name(clamp(50px, var(--width), 1000px)) // "clamp"
meta.call($function, $args...)
call($function, $args...)
- Dart Sass
- ✓
- LibSass
- since 3.5.0
- Ruby Sass
- since 3.5.0
In older versions of LibSass and Ruby Sass, the call()
function took a
string representing a function’s name. This was changed to take a function
value instead in preparation for a new module system where functions are no
longer global and so a given name may not always refer to the same function.
Passing a string to call()
still works in all implementations, but it’s
deprecated and will be disallowed in future versions.
使用 $args
调用 $function
并返回结果。
¥Invokes $function
with $args
and returns the result.
$function
必须是 函数值,例如 meta.get-function()
返回的 函数值。
¥The $function
must be a function value, such as one returned by
meta.get-function()
.
SCSS Syntax
@use "sass:list";
@use "sass:meta";
@use "sass:string";
/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition) {
$new-list: ();
$separator: list.separator($list);
@each $element in $list {
@if not meta.call($condition, $element) {
$new-list: list.append($new-list, $element, $separator: $separator);
}
}
@return $new-list;
}
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
.content {
@function contains-helvetica($string) {
@return string.index($string, "Helvetica");
}
font-family: remove-where($fonts, meta.get-function("contains-helvetica"));
}
Sass Syntax
@use "sass:list"
@use "sass:meta"
@use "sass:string"
/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition)
$new-list: ()
$separator: list.separator($list)
@each $element in $list
@if not meta.call($condition, $element)
$new-list: list.append($new-list, $element, $separator: $separator)
@return $new-list
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif
.content
@function contains-helvetica($string)
@return string.index($string, "Helvetica")
font-family: remove-where($fonts, meta.get-function("contains-helvetica"))
CSS Output
.content {
font-family: Tahoma, Geneva, Arial, sans-serif;
}
meta.content-exists()
content-exists() //=> boolean
返回当前 mixin 是否传递了 @content
块。
¥Returns whether the current mixin was passed a @content
block.
如果在 mixin 外部调用,则会抛出错误。
¥Throws an error if called outside of a mixin.
SCSS Syntax
@use 'sass:meta';
@mixin debug-content-exists {
@debug meta.content-exists();
@content;
}
@include debug-content-exists; // false
@include debug-content-exists { // true
// Content!
}
Sass Syntax
@use 'sass:meta'
@mixin debug-content-exists
@debug meta.content-exists()
@content
@include debug-content-exists // false
@include debug-content-exists // true
// Content!
meta.feature-exists($feature)
feature-exists($feature) //=> boolean
返回当前 Sass 实现是否支持 $feature
。
¥Returns whether the current Sass implementation supports $feature
.
$feature
必须是字符串。目前公认的特性有:
¥The $feature
must be a string. The currently recognized features are:
-
global-variable-shadowing
,这意味着局部变量将 阴影 为全局变量,除非它具有!global
标志。¥
global-variable-shadowing
, which means that a local variable will shadow a global variable unless it has the!global
flag. -
extend-selector-pseudoclass
,这意味着@extend
规则 将影响嵌套在伪类(如:not()
)中的选择器。¥
extend-selector-pseudoclass
, which means that the@extend
rule will affect selectors nested in pseudo-classes like:not()
. -
units-level3
,表示 单位算术 支持 CSS 值和单位级别 3 中定义的单位。¥
units-level3
, which means that unit arithmetic supports units defined in CSS Values and Units Level 3. -
at-error
,表示支持@error
规则。¥
at-error
, which means that the@error
rule is supported. -
custom-property
,这意味着 自定义属性声明 值不支持除 插值法 之外的任何 表达式。¥
custom-property
, which means that custom property declaration values don’t support any expressions other than interpolation.
对于任何无法识别的 $feature
,返回 false
。
¥Returns false
for any unrecognized $feature
.
⚠️ Heads up!
This function is deprecated and should be avoided. See [the breaking change
page] for details.
SCSS Syntax
@use "sass:meta";
@debug meta.feature-exists("at-error"); // true
@debug meta.feature-exists("unrecognized"); // false
Sass Syntax
@use "sass:meta"
@debug meta.feature-exists("at-error") // true
@debug meta.feature-exists("unrecognized") // false
meta.function-exists($name, $module: null)
function-exists($name) //=> boolean
返回名为 $name
的函数是否被定义为内置函数或用户定义函数。
¥Returns whether a function named $name
is defined, either as a built-in
function or a user-defined function.
如果传递了 $module
,这还会检查名为 $module
的模块中的函数定义。$module
必须是与当前文件中 @use
规则 的命名空间匹配的字符串。
¥If $module
is passed, this also checks the module named $module
for the
function definition. $module
must be a string matching the namespace of a
@use
rule in the current file.
SCSS Syntax
@use "sass:meta";
@use "sass:math";
@debug meta.function-exists("div", "math"); // true
@debug meta.function-exists("scale-color"); // true
@debug meta.function-exists("add"); // false
@function add($num1, $num2) {
@return $num1 + $num2;
}
@debug meta.function-exists("add"); // true
Sass Syntax
@use "sass:meta"
@use "sass:math"
@debug meta.function-exists("div", "math") // true
@debug meta.function-exists("scale-color") // true
@debug meta.function-exists("add") // false
@function add($num1, $num2)
@return $num1 + $num2
@debug meta.function-exists("add") // true
meta.get-function($name, $css: false, $module: null)
get-function($name, $css: false, $module: null) //=> function
返回名为 $name
的 函数值。
¥Returns the function value named $name
.
如果 $module
是 null
,则返回名为 $name
的函数,不带命名空间(包括 全局内置函数)。否则,$module
必须是与当前文件中 @use
规则 的命名空间匹配的字符串,在这种情况下,这将返回该模块中名为 $name
的函数。
¥If $module
is null
, this returns the function named $name
without a
namespace (including global built-in functions). Otherwise, $module
must
be a string matching the namespace of a @use
rule in the current file,
in which case this returns the function in that module named $name
.
默认情况下,如果 $name
不引用 Sass 函数,则会抛出错误。但是,如果 $css
是 true
,则返回 纯 CSS 函数。
¥By default, this throws an error if $name
doesn’t refer to Sass function.
However, if $css
is true
, it instead returns a plain CSS function.
返回的函数可以使用 meta.call()
来调用。
¥The returned function can be called using meta.call()
.
SCSS Syntax
@use "sass:list";
@use "sass:meta";
@use "sass:string";
/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition) {
$new-list: ();
$separator: list.separator($list);
@each $element in $list {
@if not meta.call($condition, $element) {
$new-list: list.append($new-list, $element, $separator: $separator);
}
}
@return $new-list;
}
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
.content {
@function contains-helvetica($string) {
@return string.index($string, "Helvetica");
}
font-family: remove-where($fonts, meta.get-function("contains-helvetica"));
}
Sass Syntax
@use "sass:list"
@use "sass:meta"
@use "sass:string"
/// Return a copy of $list with all elements for which $condition returns `true`
/// removed.
@function remove-where($list, $condition)
$new-list: ()
$separator: list.separator($list)
@each $element in $list
@if not meta.call($condition, $element)
$new-list: list.append($new-list, $element, $separator: $separator)
@return $new-list
$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif
.content
@function contains-helvetica($string)
@return string.index($string, "Helvetica")
font-family: remove-where($fonts, meta.get-function("contains-helvetica"))
CSS Output
.content {
font-family: Tahoma, Geneva, Arial, sans-serif;
}
meta.get-mixin($name, $module: null) //=> function
- Dart Sass
- since 1.69.0
- LibSass
- ✗
- Ruby Sass
- ✗
返回名为 $name
的 混入值。
¥Returns the mixin value named $name
.
如果 $module
是 null
,则返回当前模块中定义的名为 $name
的 mixin。否则,$module
必须是与当前文件中 @use
规则 的命名空间匹配的字符串,在这种情况下,这将返回该模块中名为 $name
的 mixin。
¥If $module
is null
, this returns the mixin named $name
defined in the
current module. Otherwise, $module
must be a string matching the namespace
of a @use
rule in the current file, in which case this returns the
mixin in that module named $name
.
默认情况下,如果 $name
没有引用 mixin,则会抛出错误。
¥By default, this throws an error if $name
doesn’t refer to a mixin.
返回的 mixin 可以使用 meta.apply()
包含进来。
¥The returned mixin can be included using meta.apply()
.
SCSS Syntax
@use "sass:meta";
@use "sass:string";
/// Passes each element of $list to a separate invocation of $mixin.
@mixin apply-to-all($mixin, $list) {
@each $element in $list {
@include meta.apply($mixin, $element);
}
}
@mixin font-class($size) {
.font-#{$size} {
font-size: $size;
}
}
$sizes: [8px, 12px, 2rem];
@include apply-to-all(meta.get-mixin("font-class"), $sizes);
Sass Syntax
@use "sass:meta"
@use "sass:string"
/// Passes each element of $list to a separate invocation of $mixin.
@mixin apply-to-all($mixin, $list)
@each $element in $list
@include meta.apply($mixin, $element)
@mixin font-class($size)
.font-#{$size}
font-size: $size
$sizes: 8px, 12px 2rem
@include apply-to-all(meta.get-mixin("font-class"), $sizes)
CSS Output
.font-8px {
font-size: 8px;
}
.font-12px {
font-size: 12px;
}
.font-2rem {
font-size: 2rem;
}
meta.global-variable-exists($name, $module: null)
global-variable-exists($name, $module: null) //=> boolean
返回名为 $name
(不带 $
)的 全局变量 是否存在。
¥Returns whether a global variable named $name
(without the $
) exists.
如果 $module
是 null
,则返回是否存在名为 $name
且没有命名空间的变量。否则,$module
必须是与当前文件中 @use
规则 的命名空间匹配的字符串,在这种情况下,返回该模块是否具有名为 $name
的变量。
¥If $module
is null
, this returns whether a variable named $name
without
a namespace exists. Otherwise, $module
must be a string matching the
namespace of a @use
rule in the current file, in which case this returns
whether that module has a variable named $name
.
¥See also meta.variable-exists()
.
SCSS Syntax
@use "sass:meta";
@debug meta.global-variable-exists("var1"); // false
$var1: value;
@debug meta.global-variable-exists("var1"); // true
h1 {
// $var2 is local.
$var2: value;
@debug meta.global-variable-exists("var2"); // false
}
Sass Syntax
@use "sass:meta"
@debug meta.global-variable-exists("var1") // false
$var1: value
@debug meta.global-variable-exists("var1") // true
h1
// $var2 is local.
$var2: value
@debug meta.global-variable-exists("var2") // false
meta.inspect($value)
inspect($value) //=> unquoted string
返回 $value
的字符串表示形式。
¥Returns a string representation of $value
.
返回任何 Sass 值的表示,而不仅仅是那些可以在 CSS 中表示的值。因此,不保证其返回值是有效的 CSS。
¥Returns a representation of any Sass value, not just those that can be represented in CSS. As such, its return value is not guaranteed to be valid CSS.
⚠️ Heads up!
This function is intended for debugging; its output format is not guaranteed
to be consistent across Sass versions or implementations.
SCSS Syntax
@use "sass:meta";
@debug meta.inspect(10px 20px 30px); // unquote("10px 20px 30px")
@debug meta.inspect(("width": 200px)); // unquote('("width": 200px)')
@debug meta.inspect(null); // unquote("null")
@debug meta.inspect("Helvetica"); // unquote('"Helvetica"')
Sass Syntax
@use "sass:meta"
@debug meta.inspect(10px 20px 30px) // unquote("10px 20px 30px")
@debug meta.inspect(("width": 200px)) // unquote('("width": 200px)')
@debug meta.inspect(null) // unquote("null")
@debug meta.inspect("Helvetica") // unquote('"Helvetica"')
meta.keywords($args)
keywords($args) //=> map
返回传递给采用 任意参数 的 mixin 或函数的关键字。$args
参数必须是 参数列表。
¥Returns the keywords passed to a mixin or function that takes arbitrary
arguments. The $args
argument must be an argument list.
关键字作为从作为不带引号的字符串(不包括 $
)的参数名称到这些参数的值的映射返回。
¥The keywords are returned as a map from argument names as unquoted strings
(not including $
) to the values of those arguments.
SCSS Syntax
@use "sass:meta";
@mixin syntax-colors($args...) {
@debug meta.keywords($args);
// (string: #080, comment: #800, variable: #60b)
@each $name, $color in meta.keywords($args) {
pre span.stx-#{$name} {
color: $color;
}
}
}
@include syntax-colors(
$string: #080,
$comment: #800,
$variable: #60b,
)
Sass Syntax
@use "sass:meta"
@mixin syntax-colors($args...)
@debug meta.keywords($args)
// (string: #080, comment: #800, variable: #60b)
@each $name, $color in meta.keywords($args)
pre span.stx-#{$name}
color: $color
@include syntax-colors($string: #080, $comment: #800, $variable: #60b)
CSS Output
pre span.stx-string {
color: #080;
}
pre span.stx-comment {
color: #800;
}
pre span.stx-variable {
color: #60b;
}
meta.mixin-exists($name, $module: null)
mixin-exists($name, $module: null) //=> boolean
返回名为 $name
的 混合 是否存在。
¥Returns whether a mixin named $name
exists.
如果 $module
是 null
,则返回是否存在名为 $name
且没有命名空间的 mixin。否则,$module
必须是与当前文件中 @use
规则 的命名空间匹配的字符串,在这种情况下,返回该模块是否具有名为 $name
的 mixin。
¥If $module
is null
, this returns whether a mixin named $name
without a
namespace exists. Otherwise, $module
must be a string matching the namespace
of a @use
rule in the current file, in which case this returns whether
that module has a mixin named $name
.
SCSS Syntax
@use "sass:meta";
@debug meta.mixin-exists("shadow-none"); // false
@mixin shadow-none {
box-shadow: none;
}
@debug meta.mixin-exists("shadow-none"); // true
Sass Syntax
@use "sass:meta"
@debug meta.mixin-exists("shadow-none") // false
@mixin shadow-none
box-shadow: none
@debug meta.mixin-exists("shadow-none") // true
meta.module-functions($module) //=> map
- Dart Sass
- since 1.23.0
- LibSass
- ✗
- Ruby Sass
- ✗
Only Dart Sass currently supports this function.
返回模块中定义的所有函数,作为从函数名称到 函数值 的映射。
¥Returns all the functions defined in a module, as a map from function names to function values.
$module
参数必须是与当前文件中 @use
规则 的命名空间匹配的字符串。
¥The $module
parameter must be a string matching the namespace of a @use
rule in the current file.
SCSS Syntax
// _functions.scss
@function pow($base, $exponent) {
$result: 1;
@for $_ from 1 through $exponent {
$result: $result * $base;
}
@return $result;
}
@use "sass:map";
@use "sass:meta";
@use "functions";
@debug meta.module-functions("functions"); // ("pow": get-function("pow"))
@debug meta.call(map.get(meta.module-functions("functions"), "pow"), 3, 4); // 81
Sass Syntax
// _functions.sass
@function pow($base, $exponent)
$result: 1
@for $_ from 1 through $exponent
$result: $result * $base
@return $result
@use "sass:map"
@use "sass:meta"
@use "functions"
@debug meta.module-functions("functions") // ("pow": get-function("pow"))
@debug meta.call(map.get(meta.module-functions("functions"), "pow"), 3, 4) // 81
meta.module-mixins($module) //=> map
- Dart Sass
- since 1.69.0
- LibSass
- ✗
- Ruby Sass
- ✗
返回模块中定义的所有 mixin,作为从 mixin 名称到 混入值 的映射。
¥Returns all the mixins defined in a module, as a map from mixin names to mixin values.
$module
参数必须是与当前文件中 @use
规则 的命名空间匹配的字符串。
¥The $module
parameter must be a string matching the namespace of a @use
rule in the current file.
SCSS Syntax
// _mixins.scss
@mixin stretch() {
align-items: stretch;
display: flex;
flex-direction: row;
}
@use "sass:map";
@use "sass:meta";
@use "mixins";
@debug meta.module-mixins("mixins"); // => ("stretch": get-mixin("stretch"))
.header {
@include meta.apply(map.get(meta.module-mixins("mixins"), "stretch"));
}
Sass Syntax
// _mixins.scss
@mixin stretch()
align-items: stretch
display: flex
flex-direction: row
@use "sass:map"
@use "sass:meta"
@use "mixins"
@debug meta.module-mixins("mixins") // => ("stretch": get-mixin("stretch"))
.header
@include meta.apply(map.get(meta.module-mixins("mixins"), "stretch"))
CSS Output
.header {
align-items: stretch;
display: flex;
flex-direction: row;
}
meta.module-variables($module) //=> map
- Dart Sass
- since 1.23.0
- LibSass
- ✗
- Ruby Sass
- ✗
Only Dart Sass currently supports this function.
返回模块中定义的所有变量,作为从变量名称(不带 $
)到这些变量值的映射。
¥Returns all the variables defined in a module, as a map from variable names
(without $
) to the values of those variables.
$module
参数必须是与当前文件中 @use
规则 的命名空间匹配的字符串。
¥The $module
parameter must be a string matching the namespace of a @use
rule in the current file.
SCSS Syntax
// _variables.scss
$hopbush: #c69;
$midnight-blue: #036;
$wafer: #e1d7d2;
@use "sass:meta";
@use "variables";
@debug meta.module-variables("variables");
// (
// "hopbush": #c69,
// "midnight-blue": #036,
// "wafer": #e1d7d2
// )
Sass Syntax
// _variables.sass
$hopbush: #c69
$midnight-blue: #036
$wafer: #e1d7d2
@use "sass:meta"
@use "variables"
@debug meta.module-variables("variables")
// (
// "hopbush": #c69,
// "midnight-blue": #036,
// "wafer": #e1d7d2
// )
meta.type-of($value)
type-of($value) //=> unquoted string
返回 $value
的类型。
¥Returns the type of $value
.
这可以返回以下值:
¥This can return the following values:
将来可能会添加新的可能值。对于 ()
,它可能返回 list
或 map
,具体取决于 映射函数 是否返回。
¥New possible values may be added in the future. It may return either list
or
map
for ()
, depending on whether or not it was returned by a map function.
SCSS Syntax
@use 'sass:meta';
@debug meta.type-of(10px); // number
@debug meta.type-of(10px 20px 30px); // list
@debug meta.type-of(()); // list
Sass Syntax
@use 'sass:meta'
@debug meta.type-of(10px) // number
@debug meta.type-of(10px 20px 30px) // list
@debug meta.type-of(()) // list
meta.variable-exists($name)
variable-exists($name) //=> boolean
返回当前 范围 中是否存在名为 $name
(不带 $
)的变量。
¥Returns whether a variable named $name
(without the $
) exists in the
current scope.
另见 meta.global-variable-exists()
。
¥See also meta.global-variable-exists()
.
SCSS Syntax
@use "sass:meta";
@debug meta.variable-exists("var1"); // false
$var1: value;
@debug meta.variable-exists("var1"); // true
h1 {
// $var2 is local.
$var2: value;
@debug meta.variable-exists("var2"); // true
}
Sass Syntax
@use "sass:meta"
@debug meta.variable-exists("var1") // false
$var1: value
@debug meta.variable-exists("var1") // true
h1
// $var2 is local.
$var2: value
@debug meta.variable-exists("var2") // true