我是 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 …
我正在尝试使用 访问用户的网络摄像头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)