-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
63 lines (59 loc) · 1.21 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="module">
import flatToTree from "./index.js";
const flat = [
{
key: 2,
parentId: 1,
title: "node-1-2"
},
{
key: 1,
parentId: 10,
title: "root-1"
},
{
key: 4,
parentId: 10,
title: "root-4"
},
{
key: 3,
parentId: 2,
title: "node-1-2-3"
}
];
const flat2 = [
{
id: 2,
parentId: 1,
title: "node-1-2"
},
{
id: 1,
parentId: null,
title: "root-1"
},
{
id: 3,
parentId: 2,
title: "node-1-2-3"
}
];
const tree = flatToTree(flat, {
id: "key",
// parentId: "pId",
// children: "c"
});
const tree2 = flatToTree(flat2);
console.log(tree);
console.log(tree2);
</script>
</head>
<body></body>
</html>