<template>
  <div class="page-div">
    <el-pagination
      :small="small"
      @size-change="handleSizeChange"
      :page-sizes="[5, 10, 20, 30, 40, 50, 60, 80, 100]"
      :page-size="limit"
      :current-page.sync="nowPage"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
  export default {
    name: "page",
    data() {
      return {
        nowPage: 1
      }
    },
    props: {
      'total': {
        required: true
      },
      'limit': {
        default: 10
      },
      'small': {
        type: Boolean,
        default: false
      }
    },
    watch: {
      nowPage(value) {
        this.$emit("pageChange", value);
      }
    },
    methods: {
      handleSizeChange(val) {
        this.$emit('sizeChange', val);
        this.nowPage = 1
      },
    }
  }
</script>

<style scoped>
  .page-div {
    display: block;
    text-align: center;
  }
</style>
