console
class Counter extends React.Component{
render(){
var counterStyle={
fontSize:80,
fontFamily:'sans-serif',
fontWeight: 'Bold',
padding:'25px 0px 10px 0px'
};
return <div style= {counterStyle}>{this.props.count}</div>
}
}
class CounterCase extends React.Component{
constructor(props){
super(props);
this.state={
count:0
}
}
increase(e){
var newCount;
if(e.shiftKey){
newCount= this.state.count+10;
}else{
newCount= this.state.count+1;
}
this.setState({count:newCount});
}
render(){
var caseStyle={
backgroundColor:'#ffeb3a',
width:260,
height: 200,
borderRadius: 20,
textAlign: 'center'
};
var buttonStyle={
width:35,
height: 35,
fontSize:'1em',
fontWeight: 'bold',
lineHeight: '15px',
textAlign: 'center'
}
return <div style={caseStyle}>
<Counter count={this.state.count}/>
<button style={buttonStyle} onClick={this.increase.bind(this)}> +</button>
</div>
}
}
ReactDOM.render(
<CounterCase></CounterCase>,
document.querySelector('#container9')
)
<div id="container9">
</div>
body{
background-color: #FCFCFC;
}
.container p {
font-size: 25px;
}