У меня есть дерево данных, которое я использую для представления каталога файловой системы. Это выглядит примерно так.
{
isRoot: true
path: "/path/to/dir"
fileName: "dir",
isDirectory: true,
parent: null,
children: [
{
isRoot: false
path: "/path/to/dir/file1.txt"
fileName: "file1.txt",
isDirectory: true,
parent: {...spread parent node here},
children: null
},
{
isRoot: false
path: "/path/to/dir/subdir"
fileName: "subdir",
isDirectory: true,
parent: {...spread parent node here},
children: [
{
isRoot: false
path: "/path/to/dir/subdir/file2.txt"
fileName: "file2.txt",
isDirectory: false,
parent: {...spread parent node here},
children: null
}
]
}
]
}
Я хочу взять каждый узел и превратить его в этот.
<Node branch={some parent from that tree} >
<Node branch={a child of that parent} />
<Node branch={another child of that parent>
<Node branch={a child of the new parent />
</Node>
</Node
Я знаю, что svelte позволяет вам перебирать массивы и отображать контент на основеоднако для каждого элемента невозможно узнать, как выглядит дерево.
Есть ли способ динамически визуализировать это дерево в svelte?