【发布时间】:2018-09-18 15:45:36
【问题描述】:
我正在使用 Angular 5 + Bootstrap 4,并且正在尝试制作风格主题。 我做了一些非常简单的事情,但它仍然不起作用(无法编译)。
src/style.scss:
@function theme($key: "primary") {
@return map-get($theme-colors, $key);
}
$theme-colors: (
"bg": #888,
"bg-title": #555,
"danger": #ff4136
);
* {
background: theme("bg");
}
src/app/header/header.component.scss:
* {
background: $theme("bg-title");
}
错误:
ERROR in ./src/app/header/header.component.scss
Module build failed:
background: $theme("bg-title");
^
Undefined variable: "$theme".
in C:\Users\crelierj\projects\ba\bootang\src\app\header\header.component.scss (line 2, column 15)
webpack: Failed to compile.
我了解问题所在,我在 style.scss 中定义的内容在 header.component.scss 中无法识别。 但我不知道我该怎么做?我想定义一些可以在任何组件中使用的全局函数和主题,我认为 style.scss 就是这样做的方法。
有人可以告诉我如何正确地做到这一点吗? 谢谢。
【问题讨论】:
标签: angular sass bootstrap-4