index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div>
  3. <el-alert
  4. effect="dark"
  5. :closable="false"
  6. title="基于 Element 的 Table 组件进行二次封装,实现数据驱动,支持所有 Table 参数 -- 基础表格"
  7. type="info"
  8. style="margin-bottom: 20px;"
  9. />
  10. <com-table v-loading="loading" :columns="columns" :data="tableData" />
  11. </div>
  12. </template>
  13. <script lang="ts">
  14. import { defineComponent, ref } from 'vue'
  15. const columns = [
  16. {
  17. key: 'date',
  18. label: '日期'
  19. },
  20. {
  21. key: 'name',
  22. label: '姓名'
  23. },
  24. {
  25. key: 'address',
  26. label: '地址'
  27. }
  28. ]
  29. const tableData = [
  30. {
  31. date: '2016-05-02',
  32. name: '王小虎',
  33. address: '上海市普陀区金沙江路 1518 弄'
  34. }, {
  35. date: '2016-05-04',
  36. name: '王小虎',
  37. address: '上海市普陀区金沙江路 1517 弄'
  38. }, {
  39. date: '2016-05-01',
  40. name: '王小虎',
  41. address: '上海市普陀区金沙江路 1519 弄'
  42. }, {
  43. date: '2016-05-03',
  44. name: '王小虎',
  45. address: '上海市普陀区金沙江路 1516 弄'
  46. }
  47. ]
  48. export default defineComponent({
  49. // name: 'BasicTable',
  50. setup() {
  51. const loading = ref<boolean>(true)
  52. setTimeout(() => {
  53. loading.value = false
  54. }, 1000)
  55. return {
  56. columns,
  57. tableData,
  58. loading
  59. }
  60. }
  61. })
  62. </script>
  63. <style>
  64. </style>