简体   繁体   English

Styled-Component:我想在Styled-Component中使用Variable

[英]Styled-Component : I want to use Variable in Styled-Component

I am working on app . 我正在开发应用程序。 Here I created separate file for style I used style-component for custom css but the problem is that I don't have access to use variable instead of HEX value . 在这里,我为样式创建了单独的文件,我使用样式组件来定制css,但问题是我无权使用变量而不是HEX值。 I put color value in variable but I am not able to use it in styled-component . 我把颜色值放在变量中,但我无法在样式组件中使用它。

import styled from 'styled-components';

// App Colors
let text ='#fff';

// Top Header Component Main Style
export const HeaderContainer= styled.div `
    margin-top: 67px;
    margin-left: 220px;
    margin-bottom: 30px;
    color: {text};
`

您在括号前缺少$。

color: ${text};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM