vue实现分页组件
网络编程 2021-07-04 15:50www.168986.cn编程入门
这篇文章主要为大家详细介绍了vue实现分页组件的具体代码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了vue实现分页组件的具体代码,供大家参考,具体内容如下
<template> <div class="pageBox"> <ul> <li v-if="this.condition.pageNo > 1 && this.pages.length > 4" class="sides"><a @click="prePage()"><s class="font_main"></s></a></li> <li v-for="(item, index) in pages" :class="{'curtPage': condition.pageNo == item}"> <a v-if="item" @click="goPage(item)" > <s>{{item}}</s> </a> <a href="javascript:;" rel="external nofollow" v-else>...</a> </li> <li class="sides" v-if="condition.pageNo < pageCount && this.pageCount > 4"><a @click="nextPage()"><s class="font_main"></s></a></li> </ul> </div> </template>
js中代码 page 和condition是由父组件中传过来的参数
<script> export default { props: { page: Object, condition: Object }, data () { return { pageSize: this.condition.pageSize } }, puted: { pageCount: function () { return this.page.totalCount / this.condition.pageSize > 0 ? this.page.totalCount % this.condition.pageSize === 0 ? this.page.totalCount / this.condition.pageSize : Math.ceil(this.page.totalCount / this.condition.pageSize) : 1 }, pages () { let c = this.condition.pageNo let t = this.pageCount let arr = [] if (t === 1) { return arr } if (t <= 4) { for (let i = 1; i <= t; i++) { arr.push(i) } return arr } if (c <= 3) return [1, 2, 3, 0, t] if (c >= t - 1) return [1, 0, t - 2, t - 1, t] // if (c === 4) return [1, 2, 3, 4, 5, 0, t] // if (c === (t - 2)) return [1, 0, t - 3, t - 2, t - 1, t] return [1, 0, c - 1, c, c + 1, 0, t] } }, methods: { goPage (indexPage) { if (this.indexPage !== this.condition.pageNo) { this.condition.pageNo = indexPage this.$emit('search') } }, prePage () { if (this.condition.pageNo !== 1) { this.condition.pageNo-- this.goPage(this.condition.pageNo) } }, nextPage () { if (this.condition.pageNo !== this.pageCount) { this.condition.pageNo++ this.goPage(this.condition.pageNo) } } } } </script>
效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程