有没有一种有效的方法可以在 React 组件中使用 SCSS 或 CSS 变量作为内联样式?
我想在下面做这样的事情
scss
$red: #F65959;
:root {
--red: $red;
}
js
const style = {
color: '--red',
};
export default style;
最佳答案
如果要使用 css custom properties 应该是这样的
:root {
--red: #{$red};
}
const style = {
color: 'var(--red)',
};
关于css - 在 React 组件中使用 css/scss 变量作为内联样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55142993/