物料表中的默认页面索引似乎为'0',但是要使用的api从页面索引'1'开始,如何将表格的默认页面索引更改为API的>
答案 0 :(得分:1)
您可以将 initialPage 定义为options属性的一部分,可用于定义所需的内容。检查文档here。
import MaterialTable from 'material-table';
<MaterialTable
// other props
options={{
initialPage: 1
}}
/>
我希望对您有用!
答案 1 :(得分:0)
***The Best way is***
import { TablePagination} from "@material-ui/core";
const [page, setPage] = React.useState(1);
<TablePagination page={page - 1} onChangePage={handleChangePage} />
const handleChangePage = (event, newPage) => {
setPage(newPage + 1);
};