分页

本文深入探讨了前端分页组件的实现细节,包括如何通过Vue.js动态显示分页信息,如总数据条数、当前页数和每页显示的数据数量。同时,详细介绍了分页导航的实现,如首页、上一页、下一页和尾页按钮的功能,以及如何通过选择不同的每页数据数量和手动输入页数来跳转到指定页面。

<!--分页开始-->

<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();//重新调用的接口数据

}

},

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值