解决el-pagination组件,current-page 绑定的数据变了,但是页面当前页码并没有变的问题

亲测有效!
实现:在每一次切换后将页码置为1;在当前页自由切换页码。

  1. 使用:current-page.sync
<el-pagination
   class="tc mg"
   :current-page.sync="filter.page"
   :page-sizes="[10, 20, 100, 200]"
   :page-size="filter.per_page"
   layout="total, sizes, prev, pager, next, jumper"
   :total="total_rows"
   @size-change="pageSizeChange"
   @current-change="pageCurrentChange"
 ></el-pagination>

2.在搜索函数之前将页码置为1

search(){
	this.filter.page = 1;
	...
}
  1. pageCurrentChange函数
pageCurrentChange(val) {
      this.filter.page = val;
      this.search();
}```

你可能感兴趣的:(element-ui,web前端)