https://www.runoob.com/react/react-state.html
1、状态和变量的使用
class Clock extends React.Component {
// 变量存放--固定写法
constructor() {
super();
this.state = {showWarning: 'false'}
};
//调用的方法---更改数据
tick=()=>{
this.setState({
showWarning: 123
});
}
render() {
return (
<div>
{/* 获取数据 */}
{this.state.showWarning}
<button onClick={this.tick}>点击</button>
</div>
)
}}
export default Clock;