首先第一种 ES5的写法
getInitialState: function () {
return {
currentPage: 0,
};
},
第二种 ES6的写法
constructor(props) {
super(props);
this.state = {currentPage:0};
}
但是改变状态机的方法不变 都是 通过:this.setState({currentPage:value});