index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div>
  3. <com-table :columns="columns" :data-source="data">
  4. <template #action>
  5. <a>Delete</a>
  6. </template>
  7. <template #expandedRowRender="{ record }">
  8. <p style="margin: 0">
  9. {{ record.description }}
  10. </p>
  11. </template>
  12. </com-table>
  13. </div>
  14. </template>
  15. <script lang="ts">
  16. import { defineComponent } from 'vue'
  17. import ComTable from '_c/Table'
  18. const columns = [
  19. { title: 'Name', dataIndex: 'name', key: 'name' },
  20. { title: 'Age', dataIndex: 'age', key: 'age' },
  21. { title: 'Address', dataIndex: 'address', key: 'address' },
  22. { title: 'Action', dataIndex: '', key: 'x', slots: { customRender: 'action' }}
  23. ]
  24. const data = [
  25. {
  26. key: 1,
  27. name: 'John Brown',
  28. age: 32,
  29. address: 'New York No. 1 Lake Park',
  30. description: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.'
  31. },
  32. {
  33. key: 2,
  34. name: 'Jim Green',
  35. age: 42,
  36. address: 'London No. 1 Lake Park',
  37. description: 'My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park.'
  38. },
  39. {
  40. key: 3,
  41. name: 'Joe Black',
  42. age: 32,
  43. address: 'Sidney No. 1 Lake Park',
  44. description: 'My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park.'
  45. }
  46. ]
  47. export default defineComponent({
  48. // name: 'TableExpanded',
  49. components: {
  50. ComTable
  51. },
  52. setup() {
  53. return {
  54. columns,
  55. data
  56. }
  57. }
  58. })
  59. </script>
  60. <style>
  61. </style>