index.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React from 'react';
  2. import { Table, Tooltip, Tag } from '@douyinfe/semi-ui';
  3. const Title = ({ title }) => <span style={{ fontSize: '12px', color: '#333', wordBreak: 'keep-all' }}>{title}</span>;
  4. const dataTotalSize = 46;
  5. const data = (() => {
  6. const _data = [];
  7. for (let i = 0; i < dataTotalSize; i++) {
  8. let age = (i * 1000) % 149 ;
  9. let name = `Edward King ${i}`;
  10. _data.push({
  11. key: '' + i,
  12. name,
  13. age,
  14. address: `London, Park Lane no. ${i} Lake Park`,
  15. description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
  16. });
  17. }
  18. return _data;
  19. })();
  20. const Demo = () => {
  21. const columns = [
  22. {
  23. title: <Title title="Name" />,
  24. dataIndex: 'name',
  25. width: 150,
  26. render: (text, record) => text,
  27. },
  28. {
  29. title: <Title title="Age" />,
  30. dataIndex: 'age',
  31. width: 150,
  32. render: (text, record) => text,
  33. },
  34. {
  35. title: <Title title="Address" />,
  36. dataIndex: 'address',
  37. render: (text, record) => text,
  38. },
  39. {
  40. render: (text, record) => (
  41. <Tooltip content={record.description}>
  42. <Tag color="green">Show Info</Tag>
  43. </Tooltip>
  44. ),
  45. width: 150,
  46. },
  47. ];
  48. return <Table columns={columns} dataSource={data} />;
  49. };
  50. export default Demo;