【发布时间】:2021-02-19 21:56:27
【问题描述】:
我看到 Emotion 使用 css prop 支持以下功能
const wrapperStyle = css`
display: flex;
flex-direction: column;
align-items: center;
`;
<div css={wrapperStyle}>
...
</div>
&
const color = 'white'
render(
<div
className={css`
padding: 32px;
font-size: 24px;
&:hover {
color: ${color};
}
`}
>
div content here
</div>
)
.
有没有办法使用 Styled-Components 做到这一点?
另外,使用 Styled-Components 比 Emotion 有什么优势?
【问题讨论】:
-
没有优势。 Emotion 具有与样式化组件相同的所有功能,具有样式化组件所没有的更多功能,并且速度更快。使用情感。
标签: css reactjs styled-components emotion