[英]Import scss variable into Angular component
Let's say I have the following Angular component:假设我有以下 Angular 组件:
// src/app/app.component.html
<stars [customColor]="blue">
And I have the following scss variable:我有以下 scss 变量:
// src/_styles.scss
$color: blue;
How can I use the scss
variable instead of duplicating blue
?如何使用scss
变量而不是复制blue
?
To clarify, I want to access $color
in app.component.html
or app.component.ts
.为了澄清,我想在app.component.html
或app.component.ts
中访问$color
。
Apparently it's possible to configure Webpack in a React app but I'm not sure if this is possible in Angular.显然可以在 React 应用程序中配置 Webpack,但我不确定这在 Angular 中是否可行。
In your app.component.scss
(or star.component.scss
) file just import your styles:在您的app.component.scss
(或star.component.scss
)文件中,只需导入您的 styles:
@import './../_style.scss'
Then you can use your scss var然后你可以使用你的 scss var
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.