页面展现:vue
vue组件中分页代码:ios
<div class="pagination"> <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="cur_page" :page-sizes="[1, 2, 3, 4]" :page-size="pageNum" layout="total,sizes, prev, pager, next, jumper" :total="totalCount"> </el-pagination> </div>
先声明变量:数据库
cur_page:1,//默认在第一页axios
pageNum:1,//默认每页显示1条数据api
totalCount:1,//默认总条数为一条this
一、操做每页显示几条code
//操做每页显示几条 handleSizeChange(val) { this.pageNum=val; this.getPackData();//根据用户获取的每页显示页面数量显示页面 },
二、操做当前页blog
handleCurrentChange(val) { this.cur_page = val; this.getPackData();//获取用户点击的当前页后刷新页面数据 },
三、总条数获取:get
totalPageNum(){ this.$axios.get("/api/pagePackMade.do").then(res=>{ this.totalCount =res.data[0].count;//总信息条数从数据库获取; }).catch(error=>{ console.log(error); }) },