关键代码:
this.$refs.table.bodyWrapper.scrollTop =0;
示例:
html:
<el-table ref="table"></el-table>
<el-pagination
@current-change="changePage"
:current-page.sync="cur_page"
:page-size="pageSize"
layout="total,prev, pager, next, jumper"
:total="total">
</el-pagination>
js:
//当前页码发生更改时
changePage(){ // this.getData()//请求接口,由后端控制当前页码所对应的数据 this.$refs.table.bodyWrapper.scrollTop =0; this.tableData=this.tableDataAll.slice((this.cur_page-1)*this.pageSize,this.pageSize*this.cur_page) //由前端控制当前页码所对应的数据 },