footer.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <el-table-v2 :columns="columns" :data="data" :row-height="40" :width="700" :height="400" :footer-height="50" fixed>
  3. <template #footer
  4. ><div class="flex items-center" style="justify-content: center; height: 100%; background-color: var(--el-color-primary-light-7)">Display a message in the footer</div>
  5. </template>
  6. </el-table-v2>
  7. </template>
  8. <script lang="ts" setup>
  9. const generateColumns = (length = 10, prefix = 'column-', props?: any) =>
  10. Array.from({ length }).map((_, columnIndex) => ({
  11. ...props,
  12. key: `${prefix}${columnIndex}`,
  13. dataKey: `${prefix}${columnIndex}`,
  14. title: `Column ${columnIndex}`,
  15. width: 150,
  16. }))
  17. const generateData = (columns: ReturnType<typeof generateColumns>, length = 200, prefix = 'row-') =>
  18. Array.from({ length }).map((_, rowIndex) => {
  19. return columns.reduce(
  20. (rowData, column, columnIndex) => {
  21. rowData[column.dataKey] = `Row ${rowIndex} - Col ${columnIndex}`
  22. return rowData
  23. },
  24. {
  25. id: `${prefix}${rowIndex}`,
  26. parentId: null,
  27. }
  28. )
  29. })
  30. const columns = generateColumns(10)
  31. const data = generateData(columns, 200)
  32. </script>