admin管理员组文章数量:1241092
I'm trying to use CSS-variables during the LoginPage ponent styling but receiving the following error:
SassError: Undefined variable: "$main-background-color".
This error appears in the _styles.scss
file.
this is my project structure:
I'm importing both _variables.scss
and styles.scss
to the main index.scss
file:
What I'm doing wrong while importing variables?
Why I can't use them in the _styles.scss
file?
I'm trying to use CSS-variables during the LoginPage ponent styling but receiving the following error:
SassError: Undefined variable: "$main-background-color".
This error appears in the _styles.scss
file.
this is my project structure:
I'm importing both _variables.scss
and styles.scss
to the main index.scss
file:
What I'm doing wrong while importing variables?
Why I can't use them in the _styles.scss
file?
- Path to the file is wrong from what I can tell here. Should be ../general – Phix Commented Feb 23, 2020 at 20:07
2 Answers
Reset to default 5I believe you need to import the _variables.scss
directly into _styles.scss
if you want to use them there
Is $main-background-color
your css variable (as in custom property) or did you define it as a Sass variable?
If it is an actual css variable/custom property you need to use it like this: var(--main-background-color)
and as a global variable it needs to be defined at :root {}
or any other top element like <body>
or <html>
.
If it is a Sass variable you need to make sure which file you're trying to pile. You can't pile _styles.scss
on its own, it has to be index.scss
and you need to make sure that your piler isn't trying to pile modules (files starting with _
) first as this would of course fail.
The @import
mand basically just copies everything together so loading it in multiple locations would add this multiple times. Sass modules avoid this with heir @use
mand but this is only supported in Dart Sass and not LibSass.
本文标签: javascriptSassError Undefined variable quotmainbackgroundcolorquotStack Overflow
版权声明:本文标题:javascript - SassError: Undefined variable: "$main-background-color" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740059943a2222556.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论