1 Star 0 Fork 0

Judith Huang / demos

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.jsx 709 Bytes
一键复制 编辑 原始数据 按行查看 历史
import React, { Component } from 'react'
import { Button } from 'antd'
export default class Count extends Component {
state = {
count: 0,
}
add = () => {
// 对象
// this.setState({ count: this.state.count + 1 }, () => {
// // 在更新完state、执行完render之后执行
// console.log('新的state值', this.state.count);
// });
// 函数式
this.setState(state => ({ count: state.count + 1 }), () => {
console.log('新的state值', this.state.count);
});
}
render() {
return (
<div>
<h2>当前求和的值: {this.state.count}</h2>
<Button type="primary" onClick={this.add}>点我+1</Button>
</div>
)
}
}
1
https://gitee.com/huang_juan/demos.git
git@gitee.com:huang_juan/demos.git
huang_juan
demos
demos
master

搜索帮助