index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div>
  3. <com-table
  4. :loading="loading"
  5. :columns="columns"
  6. :data-source="data"
  7. >
  8. <template #name="{text}">
  9. <a>{{ text }}</a>
  10. </template>
  11. </com-table>
  12. </div>
  13. </template>
  14. <script lang="ts">
  15. import { defineComponent, ref } from 'vue'
  16. import ComTable from '_c/Table'
  17. const columns = [
  18. {
  19. title: 'Name',
  20. dataIndex: 'name',
  21. key: 'name',
  22. slots: { customRender: 'name' }
  23. },
  24. {
  25. title: 'Age',
  26. dataIndex: 'age',
  27. key: 'age',
  28. width: 80
  29. },
  30. {
  31. title: 'Address',
  32. dataIndex: 'address',
  33. key: 'address 1',
  34. ellipsis: true
  35. },
  36. {
  37. title: 'Long Column Long Column Long Column',
  38. dataIndex: 'address',
  39. key: 'address 2',
  40. ellipsis: true
  41. },
  42. {
  43. title: 'Long Column Long Column',
  44. dataIndex: 'address',
  45. key: 'address 3',
  46. ellipsis: true
  47. },
  48. {
  49. title: 'Long Column',
  50. dataIndex: 'address',
  51. key: 'address 4',
  52. ellipsis: true
  53. }
  54. ]
  55. const data = [
  56. {
  57. key: '1',
  58. name: 'John Brown',
  59. age: 32,
  60. address: 'New York No. 1 Lake Park, New York No. 1 Lake Park',
  61. tags: ['nice', 'developer']
  62. },
  63. {
  64. key: '2',
  65. name: 'Jim Green',
  66. age: 42,
  67. address: 'London No. 2 Lake Park, London No. 2 Lake Park',
  68. tags: ['loser']
  69. },
  70. {
  71. key: '3',
  72. name: 'Joe Black',
  73. age: 32,
  74. address: 'Sidney No. 1 Lake Park, Sidney No. 1 Lake Park',
  75. tags: ['cool', 'teacher']
  76. }
  77. ]
  78. export default defineComponent({
  79. // name: 'TableEllipsis',
  80. components: {
  81. ComTable
  82. },
  83. setup() {
  84. const loading = ref<boolean>(true)
  85. setTimeout(() => {
  86. loading.value = false
  87. }, 1000)
  88. return {
  89. loading,
  90. columns,
  91. data
  92. }
  93. }
  94. })
  95. </script>
  96. <style>
  97. </style>