简体   繁体   English

我的 RGB 变量不适用于 SCSS/SASS

[英]My RGB variables are not working on SCSS/SASS

When trying to apply the following to my SCSS:尝试将以下内容应用于我的 SCSS 时:

$main__blue: 130, 207, 236;

:root {
    --main__blue: #{$main__blue};
}

h1{
  color: rgb(var(--main__blue));
}

I get the following error from compiler:我从编译器收到以下错误:

Compilation Error Error: Function rgb is missing argument $green.编译错误错误:函数 rgb 缺少参数 $green。 on line 44 of sass/c:{...}\assets\css\style.scss color: rgb(var(--main__blue));在 sass/c:{...}\assets\css\style.scss 的第 44 行颜色:rgb(var(--main__blue));

I don't want to declare the variable as RGB (in which would solve my problem), because I want later on to reuse it as an RGBA.我不想将变量声明为 RGB(这可以解决我的问题),因为我想稍后将它作为 RGBA 重用。

The strange part is that when applying the same code to my CodePen , it works perfectly.奇怪的是,将相同的代码应用于我的 CodePen时,它可以完美运行。

What am I doing wrong and how can it be solved?我做错了什么,如何解决?

VSCode with Live Sass Compiler extension.带有 Live Sass 编译器扩展的 VSCode。

The problem might be related to the VSC Live Sass Compiler.该问题可能与 VSC Live Sass 编译器有关。

Don't use this extension: Live Sass Compiler by Ritwick Dey不要使用这个扩展:Ritwick Dey 的 Live Sass Compiler

You are probably using this extension: Live Sass Compiler by Ritwick Dey.您可能正在使用这个扩展:Ritwick Dey 的 Live Sass Compiler。 It's widely used, but is no longer supported by the author.它被广泛使用,但作者不再支持。 Consequently, the SASS version isn't updated.因此,SASS 版本没有更新。 This extension might produce the error you are describing.此扩展可能会产生您描述的错误。

Use this extension: Live Sass Compiler by Glenn Marks使用这个扩展:Glenn Marks 的 Live Sass 编译器

You should use this extension: Live Sass Compiler by Glenn Marks.你应该使用这个扩展:Glenn Marks 的 Live Sass Compiler。 As the author states: A big thank you to @ritwickdey for all his work.正如作者所说:非常感谢@ritwickdey 所做的所有工作。 However, as they are no longer maintaining the original work, I have released my own which has been built upon it.然而,由于他们不再维护原始作品,我发布了我自己的作品,它是建立在它之上的。

Let me know if this is helpful.让我知道这是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM