index.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React from 'react';
  2. import { Table } from '../../../index';
  3. export default function Demo() {
  4. const columns = [
  5. {
  6. title: 'Name',
  7. dataIndex: 'name',
  8. width: '30%',
  9. render: text => <a>{text}</a>,
  10. },
  11. {
  12. title: 'combine',
  13. width: '20%',
  14. dataIndex: 'test',
  15. children: [
  16. {
  17. title: 'Age',
  18. width: '20%',
  19. children: [
  20. {
  21. title: 'Age1',
  22. width: '20%',
  23. dataIndex: 'age1',
  24. },
  25. {
  26. title: 'Age2',
  27. width: '20%',
  28. dataIndex: 'age2',
  29. },
  30. ],
  31. },
  32. {
  33. title: 'Key',
  34. width: '20%',
  35. dataIndex: 'key',
  36. },
  37. ],
  38. },
  39. {
  40. title: 'Address',
  41. width: '50%',
  42. dataIndex: 'address',
  43. },
  44. ];
  45. const data = [
  46. {
  47. key: '1',
  48. name: 'John Brown',
  49. age: 32,
  50. age1: 23,
  51. age2: 11,
  52. address: 'New York No. 1 Lake Park, New York No. 1 Lake Park',
  53. },
  54. {
  55. key: '2',
  56. name: 'Jim Green',
  57. age: 42,
  58. age1: 23,
  59. age2: 11,
  60. address: 'London No. 1 Lake Park',
  61. },
  62. {
  63. key: '3',
  64. name: 'Joe Black',
  65. age: 32,
  66. age1: 23,
  67. age2: 11,
  68. address: 'Sidney No. 1 Lake Park',
  69. },
  70. {
  71. key: '4',
  72. name: 'Disabled User',
  73. age: 99,
  74. age1: 23,
  75. age2: 11,
  76. address: 'Sidney No. 1 Lake Park',
  77. },
  78. ];
  79. return <Table columns={columns} dataSource={data} />;
  80. }