首页 文章

SASS语法错误:未定义的变量:“$ em-base”

提问于
浏览
0

我正在关注一个新的SASS structure guide here .

试图使用PX到EM mixin,似乎变量没有通过 . 但我有 base 导入 mixins 并且 typography 最后导入 .

主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);
}

Error from CodeKit:

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

1 回答

  • 1

    $em-base 未在任何文件中定义 .

相关问题