<template>
  <div  class=" flex-x-center">
    <el-pagination
      align="center"
      background
      layout="prev, pager, next,jumper"
      :current-page.sync="currentPage"
      :page-size.sync="pageSize"
      :total="total"
      v-bind="$attrs"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
// 滚动

export default {
  name: 'Pagination',
  props: {
    total: {
      required: true,
      type: Number
    },
    page: {
      type: Number,
      default: 1
    },
    pageSize:{
      type: Number,
      default: 15
    },
  },
  computed: {
    currentPage: {
      get () {
        return this.page
      },
      set (val) {
        this.$emit('update:page', val)
      }
    },
  },
  methods: {
    handleSizeChange (val) {
      this.$emit('pagination', { page: this.currentPage })

    },
    handleCurrentChange (val) {
      this.$emit('pagination', { page: val })

    }
  }
}
</script>
