React - uncaught TypeError:无法读取undefined的属性'setState'我收到以下错误未捕获的TypeError:无法读取未定义的属性“setState”甚至在构造函数中绑定delta之后。class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 1
};
this.delta.bind(this);
}
delta() {
this.setState({
count : this.state.count++
});
}
render() {
return (
<div>
<h1>{this.state.count}</h1>
<button onClick={this.delta}>+</button>
</div>
);
}}
添加回答
举报
0/150
提交
取消