小编Moh*_*mpu的帖子

sass 编译错误说 $color: null 不是颜色,即使我声明了颜色

我是 sass 新手,我写了一些 sass 代码,但它没有编译。

 $classes : primary secondary success warning danger;
    $colors : (primary:#007bff,secondary : #6c757d,success: #28a745,warning: #ffc107,dangaer: #dc3545);
    @each $class in $classes{
      .btn-#{$class}{
        $currentColor: map-get($colors,#{$class});
        background:linear-gradient(to right,$currentColor,lighten($currentColor,10%));
      }
    }
Run Code Online (Sandbox Code Playgroud)

错误是:

$color: null is not a color.
stdin 14:55  root stylesheet on line 14 at column 55
Run Code Online (Sandbox Code Playgroud)

但是当我用变量替换线性梯度时它工作正常,即

$classes : primary secondary success warning danger;
$colors : (primary:#007bff,secondary : #6c757d,success: #28a745,warning: #ffc107,dangaer: #dc3545);

    @each $class in $classes{
      .btn-#{$class}{
        $currentColor: map-get($colors,#{$class});
        background:$currentColor;
        //background:linear-gradient(to right,$currentColor,lighten($currentColor,10%));
      }
    }
Run Code Online (Sandbox Code Playgroud)

这是代码编译成功。

Linear-gradient() 函数中 $currentColor …

css sass

7
推荐指数
1
解决办法
5371
查看次数

当我尝试使用 getUserMedia() api 流式传输网络摄像头视频时,出现黑屏

我正在尝试使用 访问用户的网络摄像头navigator.getUserMedia()。我将 video.srcObject 分配给该流。但我的视频出现黑屏。我尝试过事件 navigator.mediaDevices.getUserMedia()

<video controls id="webcam"></video>
<script>
    const webcam = document.getElementById("webcam"); 
    function startVideo() {
        navigator
            .getUserMedia({
                    video: true,
                    audio: false
                },
                liveStream => {
                    console.log(liveStream);
                    webcam.setAttribute("controls", 'true');
                    webcam.srcObject = liveStream;
                    webcam.play();
                },
                error => console.log(error)
            )
    }
    startVideo();
</script>
Run Code Online (Sandbox Code Playgroud)

javascript webrtc

5
推荐指数
0
解决办法
927
查看次数

标签 统计

css ×1

javascript ×1

sass ×1

webrtc ×1