0
有人可以幫我用下面的代碼嗎?組件工作正常,但它不是渲染列表項,我無法找到一個方法來返回渲染功能列表中的項目react渲染列表項
import React from 'react'
import PageLinks from './PageLinks'
const PaginationSection = React.createClass({
onClickHandle (pageNumber) {
this.props.pageNumberClicked(pageNumber)
},
renderPageNumbers() {
let page = 1;
console.log('inside render');
while (page < this.props.totalPages) {
console.log(this.props.totalPages);
console.log(page);
if (page == this.props.currentPage) {
<li key={page}><span> </span></li>
}
else {
<li key={page}><PageLinks pageNumber={page} onPageClick={this.onClickHandle} /></li>
}
page++;
}
},
render() {
return (
<div>
{
this.props.totalPages > 1
? <ul className="pagination">
{this.renderPageNumbers()}
</ul>
: <div> </div>
}
</div>
)}
})
export default PaginationSection
非常感謝@ madox2。有效。你是一個救星.. :) :) – Mah3ndra
@ Mah3ndra歡迎您:-) – madox2