<!--分页开始-->
<div class="page flex">
<div class="page-left">
<div v-if="resFindBtn.total">
共{{resFindBtn.total}}条数据,每页{{pageValue}}条,共{{Math.ceil(resFindBtn.total / pageValue)}}页
</div>
</div>
<div class="flex alignItemCenter" v-if="resFindBtn.total">
<button class="page-btn marginRight10 cur " @click="homePage">首页</button>
<button class="page-btn marginRight10 cur" @click="prePage">上页</button>
<button class="page-btn marginRight10 cur">{{curPage}}/{{Math.ceil(resFindBtn.total / pageValue)}}</button>
<button class="page-btn marginRight10 cur" @click="nextPage">下页</button>
<button class="page-btn marginRight10 cur" @click="endPage">尾页</button>
<!--<button class="page-select marginRight10">10条/页</button>-->
<el-select v-model="pageValue" class="myInput" @change="pageChange">
<el-option
v-for="item in myPage"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<div class="marginRight10">跳至</div>
<!--<button class="page-btn marginRight10">5</button>-->
<el-input v-model="jumpPage"></el-input>
页
<button class="page-btn marginRight10 cur" @click="jumpPageHandle">确定</button>
</div>
</div>
<!--分页结束-->
curPage: '1',//当前页数
pageValue: '10', //第几页
pageCount:'',
jumpPage:'1', //跳转至xx页数
//----------------------------执行的函数---------------------------
// 切换页面
pageChange(){
this.curPage = 1;
},
//分页中首页
homePage() {
this.curPage = 1;
this.findOrder(); //重新调用的接口数据
},
prePage() {
let totalPage = Math.ceil(this.resFindBtn.total / (this.pageValue));
if (this.curPage <= totalPage && this.curPage > 1) {
this.curPage--;
this.findOrder();//重新调用的接口数据
}
},
nextPage() {
let totalPage = Math.ceil(this.resFindBtn.total / (this.pageValue));
if (this.curPage < totalPage && this.curPage >= 1) {
this.curPage++;
this.findOrder();//重新调用的接口数据
}
},
endPage() {
// 总共多少页
let totalPage = Math.ceil(this.resFindBtn.total / (this.pageValue));
this.curPage = totalPage;
this.findOrder();//重新调用的接口数据
},
jumpPageHandle() {
this.curPage = this.jumpPage;
let totalPage = Math.ceil(this.resFindBtn.total / (this.pageValue));
if (this.curPage > totalPage) {
this.endPage();
} else {
this.findOrder();//重新调用的接口数据
}
},
本文深入探讨了前端分页组件的实现细节,包括如何通过Vue.js动态显示分页信息,如总数据条数、当前页数和每页显示的数据数量。同时,详细介绍了分页导航的实现,如首页、上一页、下一页和尾页按钮的功能,以及如何通过选择不同的每页数据数量和手动输入页数来跳转到指定页面。
8034

被折叠的 条评论
为什么被折叠?



