Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sass传递映射到函数isn';不是有效的CSS值_Css_Sass - Fatal编程技术网

Sass传递映射到函数isn';不是有效的CSS值

Sass传递映射到函数isn';不是有效的CSS值,css,sass,Css,Sass,我有一个函数,它接受sassmap作为参数。问题是,当我给它一个定制的map时,它抛出: (颜色:红色)不是有效的CSS值 我希望进入if块并返回'map'字符串。我错过了什么 您的地图没有问题,但您使用的$props…: @function is-map($var){ @return type-of($var) == 'map'; } @function someFunc($props...) { @if(is-map($props...)) { /* only differenc

我有一个函数,它接受sass
map
作为参数。问题是,当我给它一个定制的
map
时,它抛出:

(颜色:红色)不是有效的CSS值


我希望进入if块并返回
'map'
字符串。我错过了什么

您的地图没有问题,但您使用的
$props…

@function is-map($var){
  @return type-of($var) == 'map';
}

@function someFunc($props...) {
  @if(is-map($props...)) { /*  only difference is the three dots you don't use */
    @return 'map';
  } @else {
    @return $props;
  }
}

h2 {
  color: someFunc((color: red));
}
请看这个

@function is-map($var){
  @return type-of($var) == 'map';
}

@function someFunc($props...) {
  @if(is-map($props...)) { /*  only difference is the three dots you don't use */
    @return 'map';
  } @else {
    @return $props;
  }
}

h2 {
  color: someFunc((color: red));
}