SASS语法错误:未定义变量:"$“em基地”;

SASS语法错误:未定义变量:"$“em基地”;,sass,mixins,Sass,Mixins,我在跟踪一个新的 尝试使用PX-to-EM mixin,但似乎无法通过变量。 但是我有基础导入混合,排版最后导入 主SASS文件: // Modules and Variables @import "modules/base"; // Partials @import "partials/normalize"; @import "partials/typography"; BASE.scss: @import "colors"; @import "fonts"; @import "anima

我在跟踪一个新的

尝试使用PX-to-EM mixin,但似乎无法通过变量。 但是我有基础导入混合排版最后导入

主SASS文件:

// Modules and Variables
@import "modules/base";

// Partials
@import "partials/normalize";
@import "partials/typography";
BASE.scss:

@import "colors";
@import "fonts";
@import "animation";
@import "mixins";
_mixins.scss:

/* PIXELS to EM */
// eg. for a relational value of 12px write em(12) when the parent is 16px
// if the parent is another value say 24px write em(12, 24)

// @include em(12);
@function em($pxval, $base: $em-base) {
    @if not unitless($pxval) {
        $pxval: strip-units($pxval);
    }
    @if not unitless($base) {
        $base: strip-units($base);
    }
    @return ($pxval / $base) * 1em;
}
最后_typography.scss:

// widget table headers
section header h1 {
    font-family: LatoRegular;
    font-size: em(18);
}
代码工具包错误:

Syntax error: Undefined variable: "$em-base".
    on line 6 of /assets/sass/partials/_typography.scss
    from line 38 of /assets/sass/dashboard.scss

$em base
在您的任何文件中都没有定义。

Ohh nice article。戴尔是个很棒的家伙!您可以尝试将您的sass放入,这样您就可以看到哪里出了问题……当然您需要先初始化$em base变量,如下所示:
$em base:16;//默认值
。看啊失败!哈哈,当em取消定义时,我看到了真正的em base,忘记了设置那个变量,一开始没有看到它
$em base:16