<el-table ref="multipleTable"
......>
<slot></slot>
</el-table>
一、table滚动到行头
this.$nextTick(() => {
this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
})
滚动到最后一行:
this.$nextTick(() => {
this.$refs.multipleTable.bodyWrapper.scrollTop = this.$refs.multipleTable.bodyWrapper.scrollHeight;
})
二、页面顶部
<div class="scrollbar" ref="viewBox">
<slot></slot>
</div>
<style>
.scrollbar {
overflow-y: auto;
}
</style>
this.$refs.viewBox.scrollTop = 0;
三、实时获取scroll value
<div class="flex-1 ev-scrollbar" ref="tableViewBox">
<slot></slot>
</div>
mounted(){
let box = this.$refs['tableViewBox'];
box.addEventListener('scroll', () => {
console.log(" scroll " + this.$refs.tableViewBox.scrollTop)
}, false);
},