我有两个组件,它们使用相同的布局/样式和不同的内容。我在React.js中使用Radium。我已经在其中一个组件中使用了内联样式,并希望对其他组件使用相同的样式。我对Radium和React都是新手。帮帮我!
提前谢谢。干杯!!
发布于 2017-03-07 10:57:59
您只需创建一个共享的外部样式文件,然后将其导入到每个需要它的组件中。
// styles.js
export default {
base: {
background: 'red'
}
}
// components
import sharedStyles from 'path/to/styles.js';
@Radium
class Button extends React.Component {
render() {
return (
<button
style={[
sharedStyles.base
]}>
{this.props.children}
</button>
);
}
}https://stackoverflow.com/questions/42638812
复制相似问题