如何从一个 SCSS 文件中导入单个变量 angular?

huangapple go评论52阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月27日 14:21:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75577302.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定