我具有用于TablePagination的此组件:
<TablePagination
rowsPerPageOptions={[5, 10, 25, 50]}
component="div"
count={rows.length}
rowsPerPage={rowsPerPage}
page={page}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
style={{width:'10px'}}
labelRowsPerPage={'Filas por página'}
labelDisplayedRows={ (from, to, count=rows.length) => (`${from}-${to === -1 ? count : to} de ${count}`)
}
/>
根据https://material-ui.com/es/api/table-pagination/
labelDisplayedRows
是func
,但我不知道这些变量from
和to
我得到:[object Object]-undefined de 11
在渲染器中
答案 0 :(得分:1)
好吧,我来自:
labelDisplayedRows={ (from=page) => (`${from.from}-${from.to === -1 ? from.count : from.to} de ${from.count}`})
答案 1 :(得分:0)
@pmiranda 它工作正常,但有一些花括号和括号的错误。
应该是:
labelDisplayedRows={(from = page) => ${from.from}-${from.to === -1 ? from.count : from.to} de ${from.count}
}