在TablePagination上反应Material-UI labelDisplayedRows

时间:2020-01-06 15:19:35

标签: material-ui

我具有用于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/

labelDisplayedRowsfunc,但我不知道这些变量fromto

在哪里定义

我得到:[object Object]-undefined de 11在渲染器中

2 个答案:

答案 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}}