1、确认组件是否写入:current-page.sync=”currentPage”
<el-pagination background :page-size="pageSize" layout="total, prev, pager, next" :total="total" :current-page.sync="currentPage" @current-change="handlePagechange" @size-change="handleSizeChange" v-if="total!=0" ></el-pagination>
##data里面定义:pageSize: 20,//我这里每页显示20条,这里可以自定义total: '',currentPage: ''
2、在页码选择的回调函数里面使用sessionStorage缓存
handlePagechange(page) {this. currentPage=page;window.sessionStorage.setItem('currentPage',page) },
3、在mounted生命周期函数获取缓存的数据,然后进行数据请求
mounted() { if( window.sessionStorage.getItem('currentPage')){ let currentPage = Number(window.sessionStorage.getItem('currentPage')); ##进行业务网络请求 }else{ ##进行业务网络请求 } },