我需要handle change()方法在Buttons组件中单击的按钮和正确答案之间进行比较,并更新计数状态或计数状态为下降状态,但是在我的情况下,这两种方法均不起作用
import Buttons from "./buttons";
class Main extends Component {
constructor(props) {
super(props)
this.state = {
Behave: false,
count: 0,
countFalls: 0,
Arr: [],
timer: 0,
}
this.HandleChange = this.HandleChange.bind(this)
}
HandleChange() {
for (let i = 0; i < Split.length; i++) {
if (Split[i] === ChoiceFour) {
this.setState(Prevstate => ({
count: Prevstate.count + 1,
arr: !Prevstate.arr
}))
}
else {
this.setState(Prevstate => ({
countFalls: Prevstate.countFalls + 1,
arr: !Prevstate.arr
}))
}
}
}
render() {
const Game = () => {
return (
<div className="border">
<Container className="Buttons">
<Row>
<Col><Buttons dices={Split} click={this.HandleChange} /></Col>
</Row>
)
}