问题:table点击分页时候,在第一页把滚动条拉到最下面,切换到第2页或第3页,滚动条还是保留上一页的位置。
预期效果:切换分页时滚动条恢复到最上面的位置!!!
//分页标签
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="queryParams.pageNum"
:page-sizes="pager.sizes"
:page-size="queryParams.pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
//选择当前页码的触发事件
handleCurrentChange(e) {
console.log(e);
this.queryParams.pageNum = e;
this.getList(); //调用列表,刷新数据
this.toTop();
},
// 定义一个回到顶部的方法,然后在el-pagination组件的current-change事件里面调用就可以了。
toTop(){
var tBody = document.querySelector('.group-table');
tBody.scrollTop = 0;
// console.log(tBody.scrollTop)
},