美文网首页
antd 表格Table滚顶到指定行

antd 表格Table滚顶到指定行

作者: 天使爱打盹 | 来源:发表于2024-07-16 15:00 被阅读0次
try {
  // 表格滚顶到指定行
  const tableEle = document.getElementById(details[0]?.patientNum)?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement
  const highlightRowEle = document.getElementById(details[0]?.patientNum)?.parentElement?.parentElement
  if(tableEle && highlightRowEle) {
    const tableEleTop = tableEle && tableEle.getBoundingClientRect().top
    const tableEleClientHeight = tableEle && tableEle.getBoundingClientRect().height
    const highlightRowEleTop = highlightRowEle && highlightRowEle.getBoundingClientRect().top
    const scroll = highlightRowEleTop - tableEleTop - tableEleClientHeight / 2
    tableEle.scrollBy({ top: scroll, behavior: 'smooth' })
  }
} catch (e) {
  console.log(e)
}

相关文章

网友评论

      本文标题:antd 表格Table滚顶到指定行

      本文链接:https://www.haomeiwen.com/subject/azukhjtx.html