From 6144a2d43143c6860ccb7a48182a1430ee07b1e7 Mon Sep 17 00:00:00 2001 From: zh-lx <18366276315@163.com> Date: Mon, 8 Nov 2021 23:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AD:=201.=E5=AE=8C=E5=96=84=E7=B1=BB?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 3ffaf4c..b160d83 100644 --- a/src/index.js +++ b/src/index.js @@ -5,14 +5,22 @@ import './index.css'; class ClassComponent extends Component { constructor(props) { super(props); - this.state = {}; + this.state = { count: 0 }; } + addCount = () => { + this.setState({ + count: this.state.count + 1, + }); + }; + render() { return (
this is a class Component
prop value is: {this.props.value}
+
count is: {this.state.count}
+
); }