visuddhinanda 3 лет назад
Родитель
Сommit
2382265b20
2 измененных файлов с 54 добавлено и 0 удалено
  1. 2 0
      dashboard/src/components/nut/Home.tsx
  2. 52 0
      dashboard/src/components/nut/TreeTest.tsx

+ 2 - 0
dashboard/src/components/nut/Home.tsx

@@ -9,6 +9,7 @@ import FontBox from "./FontBox";
 import DemoForm from "./Form";
 import WbwTest from "./WbwTest";
 import CommentList from "../comment/CommentList";
+import TreeTest from "./TreeTest";
 
 const Widget = () => {
   const data = Array(100)
@@ -29,6 +30,7 @@ const Widget = () => {
   return (
     <div>
       <h1>Home</h1>
+      <TreeTest />
       <h2>comment</h2>
       <CommentList data={data} />
       <h2>wbw</h2>

+ 52 - 0
dashboard/src/components/nut/TreeTest.tsx

@@ -0,0 +1,52 @@
+import React from "react";
+import { Tree } from "antd";
+import type { DataNode, TreeProps } from "antd/es/tree";
+
+const treeData: DataNode[] = [
+  {
+    title: "parent 1",
+    key: "0-0",
+    children: [
+      {
+        title: "parent 1-0",
+        key: "0-0-0",
+        children: [
+          {
+            title: "leaf",
+            key: "0-0-0-0",
+          },
+          {
+            title: "leaf",
+            key: "0-0-0-1",
+          },
+        ],
+      },
+      {
+        title: "parent 1-1",
+        key: "0-0-1",
+        children: [
+          {
+            title: <span style={{ color: "#1890ff" }}>sss</span>,
+            key: "0-0-1-0",
+          },
+        ],
+      },
+    ],
+  },
+];
+
+const Widget = () => {
+  const onSelect: TreeProps["onSelect"] = (selectedKeys, info) => {
+    console.log("selected", selectedKeys, info);
+  };
+
+  return (
+    <Tree
+      defaultExpandedKeys={["0-0-1-0"]}
+      onSelect={onSelect}
+      treeData={treeData}
+    />
+  );
+};
+
+export default Widget;