如何创建一个函数,在单击该数字时获取该数字的值?如果我点击 3 我想获得该值。
import { Pagination } from 'react-bootstrap';
function App() {
const [count, setCount] = useState(0);
function incrementCount() {
setCount(prevCount => prevCount + 1)
}
function decrementCount() {
setCount(prevCount => prevCount - 1)
}
let items = [];
for (let number = 1; number <= 10; number++) {
items.push(
<Pagination.Item key={number} active={number === count + 1}>
{number}
</Pagination.Item>,
);
}
const paginationBasic = (
<div>
<Pagination>
<Pagination.Prev onClick={decrementCount} />
<Pagination>{items}</Pagination>
<Pagination.Next onClick={incrementCount} />
</Pagination>
</div>
);
return (
<div>
<p>Hello Stack</p>
{paginationBasic}
</div>
);
}
暮色呼如
慕桂英546537
大话西游666
慕码人2483693
相关分类