<template>
  <div style="width: 100%;height: 100%">
    <el-table :data="tableData" style="width: 100%; margin-top: 5px">
      <el-table-column v-for="(value,key) in tableData[0]" :prop="key" :label="key"></el-table-column>
    </el-table>
    <div style="width: 100%; height: 32px">
      <el-pagination
          style="position: absolute;right: 0"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          layout="total, prev, pager, next"
          :total="data.length">
      </el-pagination>
    </div>
  </div>
</template>
<script setup>
import {computed, ref} from "vue";
const props = defineProps({
  data: Array
})
const currentPage = ref(1)
const pageSize = ref(10)
function handleCurrentChange(page) {
  currentPage.value = page;
}
function handleSizeChange(size) {
  pageSize.value = size;
}

const tableData = computed(() =>{
  const start = (currentPage.value - 1) * pageSize.value;
  const end = start + pageSize.value;
  return props.data.slice(start, end);
})
</script>
<style scoped lang="scss">

</style>