vue中前端分页的实现

查看代码

<template>
   <el-pagination
    layout="prev, pager, next"
    :page-size.sync="pager.pageSize"
    :current-page.sync="pager.currentPage"
    :total="total">
   </el-pagination>
</template>
<script>
data() {
    return {
      pager: {
        currentPage: 1,
        pageSize: 5,
      },
    };
  },

computed: {
    // 分页
    pageOrgData() {
      const start = (this.pager.currentPage - 1) * this.pager.pageSize;
      const end = this.pager.currentPage * this.pager.pageSize;
      return this.pageOrgData.slice(start, end);
    },
  },
methods:{
    // 数据排序值
    setColumnIndex(scope, pager) {
      return (scope.$index + 1) + (pager.currentPage - 1) * pager.pageSize;
    },
}
</script>

posted on   HHH_B  阅读(778)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示