【发布时间】:2017-03-21 16:34:00
【问题描述】:
有没有办法可以更改在 Angular2 组件中声明的 scss 变量?我想根据用户选择动态添加主题,因此需要修改 scss 变量。我阅读了有关将所有 scss 变量保存在单独的 scss 文件中并将其导入其他 scss 文件中的信息。但是我可以在我的组件文件中导入相同的内容并修改变量吗?这可行吗? TIA
目前我正在使用 mixin。代码在这里:
// Color themes
$themes: (
default: #ff0000,
banana: #f1c40f,
cherry: #c0392b,
blueberry: #8e44ad,
leaf: #27ae60,
nightsky: #2980b9
);
// Helper theme mixin
@mixin theme($name, $color) {
.#{$name}{
background-color: lighten($color, 30%);
}
.#{$name} {
h1{
color: $color;
}
}
.#{$name} {
nav{
a{
color: $color;
}
}
}
}
但是有没有办法可以从 Angular 组件更改 $themes 映射中的变量。
【问题讨论】:
标签: angular typescript sass angular2-components