【问题标题】:getting value from Material UI pagination从 Material UI 分页中获取价值
【发布时间】:2020-10-13 17:20:14
【问题描述】:

我需要获取所选页面的编号,以便向用户显示某些数据。 我有这个分页元素:

<Pagination count={5} variant="outlined" shape="rounded" onChange={handlePagination} />

它看起来像这样:

所以我添加了带有函数“handlepagination”的 onChange 操作,如下所示:

function handlePagination (event) {
console.log(event.currentTarget)
}

例如,当我单击 4 号按钮时,我得到以下输出:

谁能帮我获取页码,在这种情况下是“4”字符串?我试过 event.currentTarget.value 但这不起作用...

【问题讨论】:

    标签: reactjs pagination material-ui


    【解决方案1】:

    我相信您可以通过这种方式访问​​它。

    console.log(event.target.textContent)
    //or
    console.log(event.currentTarget.textContent)
    

    Here 是其他解决方案。

    【讨论】:

      猜你喜欢
      • 2013-07-24
      • 1970-01-01
      • 2022-01-22
      • 2019-03-25
      • 1970-01-01
      • 1970-01-01
      • 2020-07-06
      • 2017-05-12
      • 1970-01-01
      相关资源
      最近更新 更多