案例需求:在使用Element-ui分页组件的时候,发现一个小Bug,就是在当第一次查询数据渲染完毕以后,点击分页对应的某一页,例如当前显示第三页,这时去换一种不同的条件查询,点击查询以后,table表格数据渲染完毕以后,显示的还是第三页,不是第一页,所以此处做个小笔记
*粗略案例图
*
解决办法-- :current-page.sync=“cur_page”
<template>
<div class="pagination">
<el-pagination
@size-change="sizeChange"
@current-change="pageChange"
:current-page="data01.page"
:current-page.sync="cur_page"
:page-size="data01.rows"
:page-sizes="[50, 100, 150, 200]"
layout="total,sizes, prev, pager, next"
:total="total">
</el-pagination>
</div>
</template>
data() {
return {`
cur_page:0 //设置一个默认值
}
},
methods: {
searchClick() { //搜索
this.cur_page = 1;//cur_page 当前页
this.OMS00501() //渲染数据的函数
},
}
转载参考:https://blog.csdn.net/qq_33692349/article/details/91490480