【发布时间】:2018-02-07 07:21:55
【问题描述】:
我有一个<Section> 组件:
const styles = theme => ({
section: {
backgroundColor: theme.colors.primary,
color: theme.colors.white,
'& a:not(.button)': {
color: 'currentColor',
textDecoration: 'underline',
},
},
});
还有一个<Button> 组件:
const styles = theme => ({
button: {
backgroundColor: theme.colors.light,
color: theme.colors.dark,
padding: theme.spacing.default,
},
});
基本上,我想在<Section> 中使用<Button>,而不是覆盖它的颜色。
我不能使用& a:not($button),因为它在不同的组件中。
【问题讨论】:
-
this expects .button to be global, while it is not是什么意思? -
生成的类类似于
.is-primary-0-24 a:not(.button),但我的按钮组件生成.button-0-24。 -
那你用什么来操作 css 类名呢?