vue3+element plus封装分页

<template>
  <div 
    class="pagination flex-center" 
    :style="{
      margin: props.margin
    }">
    <el-pagination 
      class="pagination-control" 
      background 
      layout="prev, pager, next, jumper" 
      :current-page="props.current" 
      :page-size="props.size" 
      :total="props.total" 
      @current-change="onChange" />
  </div>
</template>

js代码 

<script setup>
import {
  defineProps,
  defineEmits
} from 'vue';
let props = defineProps({
  margin: {
    type: String,
    default: ()=> '60px 0 0'
  },
  // 在第几页
  current: {
    type: Number,
    default: 1
  },
  // 一页显示多少条
  size: {
    type: Number,
    default: 9
  },
  // 总数据量
  total: {
    type: Number,
    default: 0
  }
});
let emits = defineEmits([
  'onChange'
]);

const onChange = page=> {
  console.log(`第${ page }页`)
  emits('onChange',page);
}

</script>

css

<style scoped>
.pagination-control /deep/ .btn-prev,
.pagination-control /deep/ .number,
.pagination-control /deep/ .btn-next,
.pagination-control /deep/ .el-pagination__editor {
  min-width: 44px!important;
  width: 44px!important;
  height: 44px!important;
  border-radius: 12px!important;
  background-color: #fff!important;
  font-size: 16px!important;
  color: #969696!important;
  overflow: hidden;
}
.pagination-control /deep/ .number.is-active {
  background-color: #12BCFF!important;
  font-weight: normal!important;
  color: #fff!important;
}
.pagination-control /deep/ .el-input__wrapper {
  box-shadow: none!important;
}
</style>

效果展示

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值