【问题标题】:How to modify the default value of a Material UI prop-function in React JS?如何在 React JS 中修改 Material UI prop-function 的默认值?
【发布时间】:2018-05-28 10:10:50
【问题描述】:

我正在使用 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"
/>

我该怎么做? 提前谢谢你

【问题讨论】:

  • 给它一个返回你需要的字符串的函数?你的问题到底出在哪里?
  • 解决方案是这样的:Displaying pages ${from}-${to} of total ${count} pages}/>

标签: javascript reactjs material-ui


【解决方案1】:

类似这样的:

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

【讨论】:

    猜你喜欢
    • 2021-10-16
    • 2022-10-13
    • 2019-01-08
    • 2020-11-04
    • 1970-01-01
    • 1970-01-01
    • 2021-08-25
    • 2018-05-04
    • 1970-01-01
    相关资源
    最近更新 更多