修改Game组件中的render方法
render() {
const history = this.state.history;
const current = history[history.length - 1];
const winner = calculateWinner(current.juzi);
const moves = history.map((step, move) => {
const said = move ?
'开始移动' + move : '开始游戏';
return ( <
li >
<
button onClick = {
() => this.eatJuzi(move)
} > { said } <
/button> </li >
)
})
let flag;
if (flag) {
flag = '获胜者:' + winner;
} else {
flag = '下一个玩家:' + (this.state.juziIsNext ? '大橘子' : '小橘子')
}
return ( <
div className = "game" >
<
div className = "game-board" >
<
Board juzi = { current.juzi }
onClick = {
(i) => {
this.juziClick(i)
}
}
/ > < /
div > <
div className = "game-info" >
<
div > { flag } < /div> <
ol > { moves } < /ol> < /
div > <
/div>
);
}