我正在使用material-ui,并尝试使用它的一个名为backgroundColor的属性设置RaisedButton的背景色
import React, {Component} from 'react';
import RaisedButton from 'material-ui/lib/raised-button';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Home.scss';
class Home extends Component {
render() {
return (
<div>
<h1 className={s.h1}>Pomodoro Tech</h1>
<div className={s.imgContain}>
<img src={require('./pom.png')} width="100%" height="100%"/>
</div>
<div>
<RaisedButton
label="Login"
secondary={true}
backgroundColor="#77CA2D"
/>
<RaisedButton
backgroundColor="#77CA2D"
label="About"
/>
</div>
</div>
);
}
}
export default withStyles(Home, s);但是这个属性永远不会有任何不同。
根据npm list --depth=0命令的结果,我使用的material-ui的版本是0.15.0-alpha.1。
在我问这个问题之前,我已经done some search了,但不知道问题出在哪里。
发布于 2016-04-09 15:14:20
它对我来说很有效,一直在使用material-ui v0.14.4,可能它已经打入了0.15.0-alpha.1
请将工作示例粘贴到JSBin或其他地方,以便进一步调试。
发布于 2017-12-09 06:15:55
确保您没有包含primary={true};否则它将忽略您的backgroundColor。请看下面我的:
<RaisedButton
label={stepIndex === 2 ? 'Finish' : 'Next'}
disableTouchRipple={true}
disableFocusRipple={true}
onClick={this.handleNext}
backgroundColor={teal400}
/>https://stackoverflow.com/questions/36323186
复制相似问题