DictList.tsx 569 B

1234567891011121314151617181920212223242526272829
  1. import { Anchor } from "antd";
  2. const { Link } = Anchor;
  3. export interface IAnchorData {
  4. href: string;
  5. title: string;
  6. children?: IAnchorData[];
  7. }
  8. interface IWidgetDictList {
  9. data: IAnchorData[];
  10. }
  11. const Widget = (prop: IWidgetDictList) => {
  12. function GetLink(anchors: IAnchorData[]) {
  13. return anchors.map((it, id) => {
  14. return (
  15. <Link key={id} href={it.href} title={it.title}>
  16. {it.children ? GetLink(it.children) : ""}
  17. </Link>
  18. );
  19. });
  20. }
  21. return (
  22. <>
  23. <Anchor offsetTop={50}>{GetLink(prop.data)}</Anchor>
  24. </>
  25. );
  26. };
  27. export default Widget;