JSFiddle - React, Tailwind, and code Playground
by zhouyulong
HTML
<!DOCTYPE html>
<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">
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
<script>
var data = [{
id: 1,
name: "one",
pid: 0,
level: 0,
children: [{
id: 2,
name: "two",
pid: 1,
level: 1,
children: [{
id: 3,
name: "five",
pid: 2,
level: 2,
children: []
},
{
id: 4,
name: "six",
pid: 2,
level: 2,
children: []
}
]
},
{
id: 5,
name: "three",
pid: 1,
level: 1,
children: []
},
{
id: 6,
name: "four",
pid: 1,
level: 0,
children: [{
id: 7,
name: "seven",
pid: 6,
level: 2,
children: []
}]
}
]
}];
var icon = new Array('│ ', '├─ ', '└─ ');
function treeA(data) {
var str = "";
var childPrefix = "";
for (var i = 0; i < data.length; i++) {
console.log(data[i].name);
...