废话不多说了,下面给大家分享react.js翻页插件的代码,具体代码如下所示:
varPage = React.createClass({render:function(){//中间代码更新vartotalRows = this.props.totalRows;varlistRows = this.props.listRows;varnowPage = this.props.nowPage>0?this.props.nowPage:1;varfirstRow = this.props.listRows*(this.props.nowPage-1);vartotalPage = Math.ceil(totalRows/listRows);varshow_count=this.props.show_count?this.props.show_count:5;if((!totalPage)&&nowPage>totalPage){this.props.nowPage=totalPage;}if(this.props.nowPage<1){this.props.nowPage=1;}varshow_count_mid=show_count/2;varpages = [];for(vari=1;i<=show_count;i++){varpage=0;if(nowPage<=show_count_mid){page= i;}else if(nowPage+show_count_mid>totalPage){page= totalPage - show_count+i;}else{page=nowPage-Math.ceil(show_count_mid)+i;}if(page>0&&page!=nowPage){if(page<=totalPage){pages.push(<lionClick={this.props.onPagination.bind(this,page)}><a>{page}</a></li>);}}else{pages.push(<liclassName="active"><a>{page}</a></li>);}}this.pagesbutton=pages;return(this.props.totalRows>0?(<ulclassName="pagination"><li><a>Total:{this.props.totalRows} {this.props.nowPage}/{Math.ceil(this.props.totalRows/this.props.listRows)}</a></li><lionClick={this.props.onPagination.bind(this,1)}><a>firstpage</a></li><lionClick={this.props.onPagination.bind(this,this.props.nowPage==1?1:this.props.nowPage-1)}><ahref="#none">«</a></li>{this.pagesbutton}<lionClick={this.props.onPagination.bind(this,this.props.nowPage==this.props.totalPage?this.props.totalPage:this.props.nowPage+1)}><ahref="#none">»</a></li><lionClick={this.props.onPagination.bind(this,Math.ceil(this.props.totalRows/this.props.listRows))}><a>lastpage</a></li></ul>):(<ulclassName="pagination"><li><a>No data</a></li></ul>));}});
以上所述是小编给大家介绍的react.js 翻页插件实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对武林网网站的支持!
新闻热点
疑难解答