class Weather extends React.Component {
constructor(props) {
super(props);
this.state = { isHot: 'ture' }
console.log('ok');
}
render() {
const {isHot} = this.state;
console.log(isHot);
return (<div>
<input type="text"></input>
<button onClick={this.changeWeather}>今天天气</button>
<span>{isHot}</span>;
</div>)
}
changeWeather = () => {
const { isHot } = this.state;
this.setState({ isHot: !isHot });
}
}
ReactDOM.render(<Weather name='tom' age={18} />, document.querySelector('.home'));