gpt4 book ai didi

javascript - 样式组件 : I want to use Variable in Styled-Component

转载 作者:行者123 更新时间:2023-11-29 10:27:35 25 4
gpt4 key购买 nike

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

关于javascript - 样式组件 : I want to use Variable in Styled-Component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55032611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com