【发布时间】:2019-12-12 23:16:31
【问题描述】:
我正在尝试从文件中导入 .lessvariables 以在 styled-component 中使用。这可能吗?
Variables.less
@color1: #e6ae11;
@color2: #d1e4f7;
Component.jsx
import '../../../../stylesheets/variables.less';
....
const StyledDiv = styled.div`
text-align: right;
color: @color1
`;
【问题讨论】:
-
这能回答你的问题吗? How to use LESS variable in React JS
-
我个人在我的堆栈中使用 less 模块(css 模块使用 less),它允许您将所有内容从 less 文件传递到 js。 Here's an article with further details on how to set it up
-
抱歉,现在是清晨。我将
LESS和CSS混合在一起,我实际上并不想这样做。对于这种情况,我将坚持使用.less文件。谢谢大家的帮助
标签: javascript reactjs less styled-components