實現原理:
判斷表格在頁面scrollTop高度,代替表格指定行高度,因此獲取到表格父元素--滾動元素,然后賦值即可
判斷Dom節點是否是滾動元素
window.addEventListener('scroll', () => {
var scrollTop = document.getElementsByClassName('ant-table-body')[0];
console.log(scrollTop.scrollTop) // 查看打印的值是否有變化 如果有 則說明滾滾動條在這個標簽中
}, true)
滾動到指定位置(historyHeight賦值,記錄表格歷史位置)
const historyHeight = ref(null);
const goHistoryPosition = () => {
let aaa = document.getElementsByClassName('ant-table-body')[0];
aaa.scrollTop = historyHeight.value;
};