vue3 分页组件的封装 el-pagination以及调用

效果图:

在这里插入图片描述

组件封装代码:

<script setup>
import { toRefs } from 'vue';
import { ElPagination } from 'element-plus';

const props = defineProps({
  pageIndex: Number,
  pageSize: Number,
  total: Number,
});

const { pageIndex, pageSize, total } = toRefs(props);

const emit = defineEmits(['onChangePage']);

const changePage = (page) => {
  emit('onChangePage', page);
};
</script>

<template>
  <ElPagination
    v-model:current-page="pageIndex"
    v-model:page-size="pageSize"
    class="lj-paging"
    layout="total, prev, pager, next, jumper"
    :pager-count="5"
    :total="total"
    @current-change="changePage"
  />
</template>

<style lang="scss" scoped>
.lj-paging {
  :deep(button) {
    width: 25px;
    height: 25px;
    margin: 0 4px;
    border-radius: 50%;
    i {
      font-size: 18px !important;
    }
  }
  :deep(.el-pager) {
    li {
      width: 25px;
      height: 25px;
      margin: 0 4px;
      color: #4382bc;
      font-size: 12px;
      line-height: 25px;
      border-radius: 50%;

      &.is-active {
        color: #00f2fb;
        font-weight: normal;
        background: none;
        border: 1px solid #00f2fb;
        box-shadow: 0 0 10px 0#00f2fb;
      }
    }
  }
  :deep(.el-pagination__jump) {
    font-size: 12px;
  }
  :deep(.el-input__inner) {
    font-size: 12px !important;
  }
}
</style>

调用:

 <PageIndex :total="100" :page-index="1" :page-size="10" @on-change-page="onChangePage" />

相关推荐

  1. react基于antd二次封装组件Pagination

    2024-03-20 15:04:04       37 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-20 15:04:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-20 15:04:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-20 15:04:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-20 15:04:04       20 阅读

热门阅读

  1. uniapp 兼容pc与手机的样式方法

    2024-03-20 15:04:04       19 阅读
  2. 商品规格存储问题

    2024-03-20 15:04:04       20 阅读
  3. 实现:mysql-5.7.42 到 mysql-8.2.0 的升级(rpm方式)

    2024-03-20 15:04:04       17 阅读
  4. MySQL TRIM函数

    2024-03-20 15:04:04       19 阅读
  5. 工作岗位(主要是Qt相关)

    2024-03-20 15:04:04       17 阅读
  6. uncaught error: dynamic require of “buffer“ is not supported

    2024-03-20 15:04:04       21 阅读
  7. 信息化项目可研报告模板(第五章)

    2024-03-20 15:04:04       16 阅读
  8. 深度学习常见的三种模型

    2024-03-20 15:04:04       22 阅读
  9. AI助力快速定位数据库难题

    2024-03-20 15:04:04       20 阅读
  10. 栈和队列章节课后习题答案集锦

    2024-03-20 15:04:04       21 阅读
  11. C语言之婚礼上的谎言

    2024-03-20 15:04:04       20 阅读
  12. 每天学习一个Linux命令之vim

    2024-03-20 15:04:04       23 阅读