【问题标题】:Sass Syntax Error: wrong number of arguments (1 for 3) for `rgb'Sass 语法错误:“rgb”的参数数量错误(1 对 3)
【发布时间】:2020-08-12 22:12:24
【问题描述】:

我使用 Ruby On Rails 5 和 gem sass-rails 5.0

由于某种原因,我收到一条错误消息:

`rgb' 的参数数量错误(1 对 3)

在文件 app/assets/stylesheets/main.css.scss 的第 2 行

$main-color-raw: rgb(0,80,170);
$main-color: rgb($main-color-raw);
$main-color-bright: rgba($main-color-raw, 0.5);

我尝试使用十六进制颜色值而不是 rgb():

$main-color-raw: #0050aa;

但是得到同样的错误信息。

看起来 sass 变量 $main-color-raw 未正确评估,可能是 rails-sass gem 配置错误。

所以我在我的 config/application.rb 中添加了

config.sass.preferred_syntax = :scss
config.sass.line_comments = false
config.sass.cache = false

来自 rails-sass github 文档页面。

但还是同样的错误。

我该如何解决?

【问题讨论】:

    标签: ruby-on-rails sass


    【解决方案1】:
    $main-color-raw: rgb(0,80,170);
    

    所以在$main-color,你有:

    $main-color: rgb(rgb(0,80,170));
    

    所以您只将 1 个参数传递给 rgb。

    您应该将 main-color-raw 声明为:

    $main-color-raw: 0, 80, 170;
    

    【讨论】:

    • 谢谢@nuaky,就是这样!我觉得声明一个包含多个逗号分隔值的变量很不舒服,所以我使用了 $main-color: $main-color-raw;而是
    猜你喜欢
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 2020-12-12
    相关资源
    最近更新 更多