更改React中的SASS模块变量
变量
$max-width: 100%;
:export {
maxWidth: $max-width
}
具有
import styles from "../styles/Card.module.scss"
我在card.module.scss
中 使用styles.maxwidth
访问此值,但我不知道如何更改该值。
我知道使用css
自定义属性会更容易,但是在模块中不起作用,因为它不是纯粹的选择器。
I have a variable in my Card.module.scss
and use this code to export it make it available to my React components:
$max-width: 100%;
:export {
maxWidth: $max-width
}
I import this and the rest of the styles with:
import styles from "../styles/Card.module.scss"
and I'm able to access this value using styles.maxWidth
, but I don't know how to change the value.
I know it would be easier to use CSS
custom properties, but that would not work in modules, as it would not be a pure selector.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这实际上是不可能的:Sass是在构建中编译成常规CSS的,因此在运行时尝试修改它是没有意义的。您可能必须使用自定义属性...
如果有更多知识的人可以确认...
I don't believe it's actually possible: SaSS is compiled on build into regular CSS, so it makes no sense to try and modify it at runtime. You will probably have to use custom properties...
If anyone more knowledgable can confirm...