Use elementUI paging in vue to return to the top of the page when switching pages

principle:

Add a method to jump to the top of the page when the elementUI paging component triggers an event when switching pages (here, the handleCurrentChange function).

accomplish:

<!-- 分页组件 -->
<el-pagination
 @current-change="handleCurrentChange"
 >
</el-pagination>
//跳到页顶
scrollTop(selector) {
    
    
  let element = selector && document.querySelector(selector) || window;
  element.scrollTo(0, 0);
},

handleCurrentChange(val) {
    
    
	...
	this.scrollTop()
}

Guess you like

Origin blog.csdn.net/jiangjunyuan168/article/details/124710071