element-ui表格定位到某一行


/**
* @description: 通過表格索引 定位表格的位置
* @param {refName} table的ref值
* @param {index} table的索引值
* @return:
* @author: ywj
*/
$tableScrollMove(refName,index=0){
if(!refName || !this.$refs[refName]) return//不存在表格的ref vm 則返回
let vmEl = this.$refs[refName].$el
if(!vmEl) return
//計算滾動條的位置
const targetTop = vmEl.querySelectorAll('.el-table__body tr')[index].getBoundingClientRect().top
const containerTop = vmEl.querySelector('.el-table__body').getBoundingClientRect().top
const scrollParent = vmEl.querySelector('.el-table__body-wrapper')
scrollParent.scrollTop = targetTop - containerTop
},

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM