您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
怎么在vue项目中使用分页插件?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
分页插件代码:
<div> <div class="page"> <div class="pagelist"> <span class="jump" :class="{disabled:pstart}" @click="lessPage()">上一页</span> <span v-show="current_page>5" class="jump" @click="jumpPage(1)">1</span> <span class="ellipsis" v-show="efont">...</span> <span class="jump" v-for="num in indexs" :class="{bgprimary:current_page==num}" @click="jumpPage(num)">{{num}}</span> <span class="ellipsis" v-show="ebehind">...</span> <span :class="{disabled:pend}" class="jump" @click="addPage()">下一页</span> <span v-show="current_page<pages-4" class="jump" @click="jumpPage(pages)">{{pages}}</span> <#--<span class="jumppoint">跳转到:</span>--> <#--<span class="jumpinp"><input type="text" v-model="changePage"></span>--> <#--<span class="jump gobtn" @click="jumpPage(changePage)">GO</span>--> </div> </div> </div>
vue代码
data: { current_page: result.resultObj.number + 1, //当前页 pages: result.resultObj.totalPages, //总页数 changePage: '',//跳转页 nowIndex: 0 }, computed: { show: function () { return this.pages && this.pages != 1 }, pstart: function () { return this.current_page == 1; }, pend: function () { return this.current_page == this.pages; }, efont: function () { if (this.pages <= 7) return false; return this.current_page > 5 }, ebehind: function () { if (this.pages <= 7) return false; var nowAy = this.indexs; return nowAy[nowAy.length - 1] != this.pages; }, indexs: function () { var left = 1, right = this.pages, ar = []; if (this.pages >= 7) { if (this.current_page > 5 && this.current_page < this.pages -4){ left = Number(this.current_page) - 3; right = Number(this.current_page) + 3; } else { if (this.current_page <= 5) { left = 1; right = 7; } else { right = this.pages; left = this.pages - 6; } } } while (left <= right) { ar.push(left); left++; } return ar; }, }, methods: { jumpPage: function (id) { if (id <= this.pages && id >= 1) { this.current_page = id; loadData(this.current_page - 1, size); } }, lessPage: function () { this.current_page--; loadData(this.current_page - 1, size); }, addPage: function () { this.current_page++; loadData(this.current_page - 1, size); } }
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。