【问题标题】:Styled-Component : I want to use Variable in Styled-ComponentStyled-Component:我想在 Styled-Component 中使用变量
【发布时间】:2019-07-28 16:18:44
【问题描述】:

我正在开发应用程序。在这里,我为样式创建了单独的文件,我将 style-component 用于自定义 css,但问题是我无法访问使用变量而不是 HEX value 。我将颜色值放入变量中,但无法在 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};
`

【问题讨论】:

    标签: javascript reactjs ecmascript-6 styled-components


    【解决方案1】:

    括号前少了一个 $。

    color: ${text};
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-23
      • 2021-07-19
      • 2022-11-29
      • 2020-03-19
      • 2019-05-11
      • 2021-10-31
      • 2020-11-20
      • 2021-01-11
      相关资源
      最近更新 更多