Table表格

  1. import { Typography, Carousel, Image, Rate, Table } from "antd";
  2. import { ColumnsType } from "antd/es/table";
  3. // interface PropsType...
  4. const columns: ColumnsType<RowType> = [
  5. {
  6. title: "title",
  7. dataIndex: "title",
  8. key: "title",
  9. align: "left",
  10. width: 120,
  11. },
  12. {
  13. title: "description",
  14. dataIndex: "description",
  15. key: "description",
  16. align: "center",
  17. },
  18. ];
  19. interface RowType {
  20. title: string;
  21. description: string | number | JSX.Element;
  22. key: number;
  23. }
  24. export const ProductIntro: React.FC<PropsType> = ({title,shortDescription,price,coupons,discount,rating,pictures,
  25. }) => {
  26. const tableDataSource: RowType[] = [
  27. {
  28. key: 0,
  29. title: "路线名称",
  30. description: title,
  31. },
  32. {
  33. key: 1,
  34. title: "价格",
  35. description: (
  36. <>
  37. ¥{" "}
  38. <Typography.Text type="danger" strong>
  39. {price}
  40. </Typography.Text>
  41. </>
  42. ),
  43. },
  44. {
  45. key: 2,
  46. title: "限时抢购折扣",
  47. description: discount ? (
  48. <>
  49. ¥ <Typography.Text delete>{price}</Typography.Text>{" "}
  50. <Typography.Text type="danger" strong>
  51. ¥ {discount}
  52. </Typography.Text>
  53. </>
  54. ) : (
  55. "暂无折扣"
  56. ),
  57. },
  58. {
  59. key: 2,
  60. title: "领取优惠",
  61. description: coupons ? discount : "无优惠券可领",
  62. },
  63. {
  64. key: 2,
  65. title: "线路评价",
  66. description: (
  67. <>
  68. <Rate allowHalf defaultValue={+rating} />
  69. <Typography.Text style={{ marginLeft: 10 }}>
  70. {rating}
  71. </Typography.Text>
  72. </>
  73. ),
  74. },
  75. ];
  76. return (
  77. <div className={styles["intro-container"]}>
  78. {// ...}
  79. <Table<RowType>
  80. columns={columns}
  81. dataSource={tableDataSource}
  82. size="small"
  83. bordered={false}
  84. pagination={false}
  85. showHeader={false}
  86. />
  87. </div>
  88. );
  89. };

在React中插入HTML数据

  1. <div
  2. dangerouslySetInnerHTML={{ __html: product.fees }}
  3. style={{ margin: 50 }}
  4. ></div>

锚点菜单

  1. <Anchor className={styles["product-detail-anchor"]}>
  2. <Menu mode="horizontal">
  3. <Menu.Item key="1">
  4. <Anchor.Link href="#feature" title="产品特色"></Anchor.Link>
  5. </Menu.Item>
  6. <Menu.Item key="3">
  7. <Anchor.Link href="#fees" title="费用"></Anchor.Link>
  8. </Menu.Item>
  9. <Menu.Item key="4">
  10. <Anchor.Link href="#notes" title="预订须知"></Anchor.Link>
  11. </Menu.Item>
  12. <Menu.Item key="5">
  13. <Anchor.Link href="#comments" title="用户评价"></Anchor.Link>
  14. </Menu.Item>
  15. </Menu>
  16. </Anchor>

评论列表

  1. import { Comment, Tooltip, List } from "antd";
  2. import React from "react";
  3. interface PropsType {
  4. data: {
  5. author: string;
  6. avatar: string;
  7. content: string;
  8. createDate: string;
  9. }[];
  10. }
  11. export const ProductComments: React.FC<PropsType> = ({data}) => {
  12. return (
  13. <List
  14. dataSource={data}
  15. itemLayout="horizontal"
  16. renderItem={(item) => {
  17. return (
  18. <li>
  19. <Comment
  20. author={item.author}
  21. avatar={item.avatar}
  22. content={item.content}
  23. datetime={item.createDate}
  24. />
  25. </li>
  26. );
  27. }}
  28. ></List>
  29. );
  30. }