首页 > 解决方案 > 如何在 React JS 中修改 Material UI prop-function 的默认值?

问题描述

我正在使用 React JS,我已经从 Material UI 导入了一个名为(https://material-ui.com/api/table-pagination/)的组件,我想修改 labelDisplayedRows 的默认值,现在就像这个:

({ from, to, count }) => ${from}-${to} of ${count}

我想编辑输出的“of”,但它是一个函数,所以我不知道该怎么做。如果它是像 labelRowsPerPage 这样的简单节点,我会通过编写来修改它

<TablePagination
                    labelRowsPerPage="text text text"
/>

我怎么能做到?先感谢您

标签: javascriptreactjsmaterial-ui

解决方案


像这样的东西:

<TablePagination labelDisplayedRows={({ from, to, count }) => `Displaying pages ${from}-${to} of total ${count} pages`}/>

推荐阅读