Styled-Component :我想在 Styled-Component 中使用 Variable
Styled-Component : I want to use Variable in Styled-Component
我正在开发应用程序。在这里,我为样式创建了单独的文件,我使用 style-component 自定义 css 但问题是我无权使用 variable 而不是 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};
`
您在括号前少了一个 $。
color: ${text};
我正在开发应用程序。在这里,我为样式创建了单独的文件,我使用 style-component 自定义 css 但问题是我无权使用 variable 而不是 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};
`
您在括号前少了一个 $。
color: ${text};