Vue 分页器组件[通俗易懂]

Vue 分页器组件[通俗易懂]<template><divclass=”pagination”><button>上一页</button><button@click=”changecurentpage(1)”v-if=”startEnd.start>1″>1</button><buttonv-if=”startEnd.start>2″>···</button><.

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

<template>
  <div class="pagination">
    <button>上一页</button>
    <button @click="changecurentpage(1)" v-if="startEnd.start > 1">1</button>
    <button v-if="startEnd.start > 2">···</button>

    <button @click="changecurentpage(startEnd.start+index)" v-for="(item,index) in continuPage" :key="index">{
  
  {startEnd.start+index}}</button>


    <button v-if="startEnd.end < pagesTotal -1">···</button>
    <button @click="changecurentpage(pagesTotal)" v-if="startEnd.end < pagesTotal">{
  
  {pagesTotal}}</button>
    <button>下一页</button>

    <button style="margin-left: 30px">{
  
  {currentPageNo}}/{
  
  {pagesTotal}}页</button>
  </div>
</template>

<script>
export default {
  props: ['currentPageno','pageSize','total','continuPage'],
  data() {
    return {
      currentPageNo : this.currentPageno
    }
  },
  methods: {
    changecurentpage(currentPageNo) {
      // if(this.startEnd.end)
      this.currentPageNo = currentPageNo
    }
  },
  computed: {
    pagesTotal() {
      return Math.ceil(this.total/this.pageSize)
    },
    startEnd() {
      let {currentPageNo,continuPage} = this
      let start = currentPageNo-parseInt(continuPage/2)
      if (start < 1) start = 1
      let end = currentPageNo+parseInt(continuPage/2)
      if (end > this.pagesTotal) {
        end = this.pagesTotal
        start = end - continuPage +1
      }
      return {start, end}
    }
  }
};
</script>

<style lang="less" scoped>
.pagination {
  text-align:center;
  button {
    margin: 0 5px;
    background-color: #f4f4f5;
    color: #606266;
    outline: none;
    border-radius: 2px;
    padding: 0 4px;
    vertical-align: top;
    display: inline-block;
    font-size: 13px;
    min-width: 35.5px;
    height: 28px;
    line-height: 28px;
    cursor: pointer;
    box-sizing: border-box;
    text-align: center;
    border: 0;

    &[disabled] {
      color: #c0c4cc;
      cursor: not-allowed;
    }

    &.active {
      cursor: not-allowed;
      background-color: #409eff;
      color: #fff;
    }
  }
}
</style>

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/187346.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java motherfree video_Java Config 下的Spring Test方式

    java motherfree video_Java Config 下的Spring Test方式用了三种方式:1.纯手动取bean:packagecom.wang.test;importcom.marsmother.commission.core.config.MapperConfig;importcom.marsmother.commission.core.config.PropertyConfig;importcom.marsmother.commission.core.conf…

    2022年7月7日
    23
  • PLSQL Developer新手使用教程(图文教程)(转载)[通俗易懂]

    PLSQL Developer新手使用教程(图文教程)(转载)[通俗易懂]原文:https://www.cnblogs.com/wangfuyou/p/5915246.html PLSQLDeveloper是Oracle数据库开发工具,很牛也很好用,PLSQLDeveloper功能很强大,可以做为集成调试器,有SQL窗口,命令窗口,对象浏览器和性能优化等功能,下面简单的介绍一下如何使用PLSQLDeveloper工具,新手教程。1.基本操作1)首先确保…

    2022年5月2日
    120
  • Microsoft Office Excel 不能访问文件 的解决办法

    Microsoft Office Excel 不能访问文件 的解决办法

    2022年3月5日
    397
  • Go语言之append函数

    Go语言之append函数append函数的作用官方解释append函数是向slice里面追加一个或多个元素,然后返回一个和slice一样类型的slice,其签名为funcappend(slice[]T,elements…T)[]Tappend所做的是在切片尾添加元素并返回结果。结果需要返回因为,正如我们手写的Append,底层的数组可能更改。使用示例:x:=[]int{1,2

    2022年6月18日
    44
  • egg yolk_人类蛋白数据库

    egg yolk_人类蛋白数据库欢迎关注”生信修炼手册”!直系同源蛋白的预测在系统发育,比较基因组学等多个领域都占用重要地位,COG数据库开创了同源蛋白数据库的先河,后续又不断有新的数据库涌现,而eggNOG就是目前使…

    2025年6月30日
    3
  • Crackme 23[通俗易懂]

    Crackme 23[通俗易懂]Crackme23这题很好,一环扣一环。题目出的比较细致,有很多细节问题需要注意。也有此题看出,Crackme不能急,要一步一步的来

    2025年7月15日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号