英文:
How to import a single variable from a scss file angular?
问题
I have a global styles.scss file where I have declared some variables. I need to use this variable in a component's scss file. I know I can declare a class in styles.scss using this variable and then use this class in my components template file, but the elements on which I want to use these variables are generated later, so I am using ng-deep in my components scss file and applying css rules in this ng-deep. I don't want to import the entire styles.scss file as it is very large. Is there a way in which I can import only a single or a list of variables from styles.scss into my components scss file?
英文:
I have a global styles.scss file where I have declared some variables. I need to use this variable in a component's scss file. I know I can declare a class in styles.scss using this variable and then use this class in my components template file, but the elements on which I want to use these variables are generated later, so I am using ng-deep in my components scss file and applying css rules in this ng-deep. I don't want to import the entire styles.scss file as it is very large. Is there a way in which I can import only a single or a list of variables from styles.scss into my components scss file?
答案1
得分: 1
我不认为以那种方式是可能的。如果你不想导入完整的 styles.scss
,也许你可以将变量放在另一个 scss 文件
中,比如 variables.scss
,然后在 styles.scss
和你的 组件的 scss
中都导入 variables.scss
。
英文:
I don't think it is possible that ways. If you do not want to import complete styles.scss
, maybe you can put the variables in another scss file
, let's say variables.scss
and import variables.scss
in both styles.scss
as well as your component's scss
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论