这是组成树形结构的第二种方法,———–下面是代码
const TreeData=[
{ id:1,
parentId:-1,
guid:"5bc9ec72-b9cd-4a85-a04e-56260f368d9d",
parentGuid:"00000000-0000-0000-0000-000000000000",
name:"南充分行",
},
{ id:2,
parentId:1,
guid:"fd16c3a8-321c-47fd-8121-4c3756449932",
parentGuid:"5bc9ec72-b9cd-4a85-a04e-56260f368d9d",
name:"南充分行下的1",
},
{ id:3,
parentId:1,
guid:"1200819a-5c12-4851-9d05-c2e8854c2fe0",
parentGuid:"5bc9ec72-b9cd-4a85-a04e-56260f368d9d",
name:"南充分行下的2",
},
{ id:4,
parentId:-1,
guid:"d52bad43-12ad-4533-ad24-ea8be67d2713",
parentGuid:"00000000-0000-0000-0000-000000000000",
name:"成都分行",
},
{ id:5,
parentId:4,
guid:"23d186aa-30e9-4d9b-abac-62e383124576",
parentGuid:"d52bad43-12ad-4533-ad24-ea8be67d2713",
name:"成都分行下的1",
},
{ id:6,
parentId:4,
guid:"b3c787b2-d954-48d8-a9fc-43be666c396b",
parentGuid:"d52bad43-12ad-4533-ad24-ea8be67d2713",
name:"成都分行下的2",
},
{ id:7,
parentId:6,
guid:"db1b2460-46f6-43c8-8c20-737322fdaa10",
parentGuid:"b3c787b2-d954-48d8-a9fc-43be666c396b",
name:"成都分行2下的1",
},
{ id:8,
parentId:6,
guid:"427e12dc-7fb2-4939-aae9-6c8e1511f3e2",
parentGuid:"b3c787b2-d954-48d8-a9fc-43be666c396b",
name:"成都分行2下的1",
},
上面的数据也是一种树形结构,父节点的id等于子节点的parentI的,父节点的guid等于子节点的parentGuid
const parent=[
{
id:1,
name:"报警设备1",
guid:"3cf6a90a-94c1-49a3-8ab0-c6acc6fc9a16",
},
{
id:2,
name:"报警设备2",
guid:"c20f6343-8a09-400e-8405-d5b0b8353cf6",
},
{
id:3,
name:"报警设备3",
guid:"e1f3420d-dced-49a1-87a6-c976e1a8bc13",
},
];
const children=[
{
id:1,
name:"报警输入1",
guid:"b3e445ac-1742-4cb3-84cb-bfce9f7e9333",
deviceId:1,
},
{
id:2,
name:"报警输入2",
guid:"2f846f3d-d57e-48a5-aa9e-c2c9d164c024",
deviceId:1,
},
{
id:3,
name:"报警输入3",
guid:"d4aa49b7-13b9-4200-8c7a-96fee44797ea",
deviceId:1,
},
{
id:4,
name:"报警输入4",
guid:"90a288e9-aca5-404f-b767-c4ee54f20368",
deviceId:1,
},
{
id:5,
name:"报警输入5",
guid:"b15a0c29-aa55-4c3c-a298-f59beaf98535",
deviceId:1,
},
];