SASS | Функции карты
Опубликовано: 2 Марта, 2022
Тип данных SASS Map используется для отображения одной или нескольких пар ключ-значение. Наряду с функциями карты, показанными в нижеследующих списках, вы также можете использовать любую из функций списка SASS с картами.
The following lists contains all map functions in SASS:
- map-has-key($map, $key) function: This function returns a Boolean value that checks whether the given map contains the given key or not.
- Example:
map-has-key((
"red"
:
#ff0000
,
"yellow"
:
#ffff00
),
blue
)
- Output:
false
- Example:
- map-merge($map1, $map2) function: This function returns a map containing $map2 joined to the end of $map1.
- Example:
map-merge((
"red"
:
#ff0000
,
"yellow"
:
#ffff00
), (
"blue"
:
#0000ff
)
- Output:
("red": #ff0000, "yellow": #ffff00, "blue": #0000ff)
- Example:
- map-keys($map) function: This function returns the list of the keys in the given map.
- Example:
map-keys((
"red"
:
#ff0000
,
"yellow"
:
#ffff00
))
- Output:
("red", "yellow")
- Example:
- map-remove($map, $keys) function: This function returns a map without the given keys.
- Example:
map-remove((
"red"
:
#ff0000
,
"yellow"
:
#ffff00
),
"red"
)
- Output:
("yellow": #ffff00)
- Example:
- map-values($map) function: This function returns the list of the values in the given map.
- Example:
map-values((
"red"
:
#ff0000
,
"yellow"
:
#ffff00
))
- Output:
(#ff0000, #ffff00)
- Example:
- map-get($map, $key) function: This function returns the value associated with the given key.
- Example:
map-get((
"blue"
:
#0000ff
,
"yellow"
:
#ffff00
),
"blue"
)
- Output:
#0000ff
- Example: