我想在状态 == 循环索引时将项目设置为活动状态。但我每次都变得虚假。
constructor(props) {
super(props);
this.state = {
currentPage: this.props.currentPage
};
}
render() {
var lis = [];
for (var i=1; i <= this.props.totalPages; i++) {
lis.push(
<PaginationItem
key={i}
active={
this.state.currentPage === {i} ? true : false
}
>
<PaginationLink href="javascript:void(0)" onClick={this.handlePageClick.bind(this, i)} >
{i}
</PaginationLink>
</PaginationItem>
);
}
}