【发布时间】:2018-12-03 15:17:51
【问题描述】:
是否可以将全局 CSS 类注入 styled-component?
类似于在 LESS 中使用 &:extend 或 @extend 在 SASS 中扩展。
此代码不适用于globalCSS 样式:
const extendedComponent = styled.div`
&:extend(.globalClass) // I want this component to inherit all styles of .globalaCSS
.otherStyles {
...
}
`
globalClass 在内联使用时会退出,甚至会应用样式:
extendedComponent(className="globalCSS)
【问题讨论】:
标签: css reactjs styled-components