var data = [{
name:1,
next:[{name:4},{name:999}]
},{name:2},{name:3}]
function clickMod(){
return function(){
alert("hhhhhhhhh")
}
}
function styleName(){
return {
background:'green',
color:'red',
marginBottom:'50px'
}
}
function createTreeDate(data){
if(data){
let lis=[];
for(let index in data){
console.log("index:",index)
let childrenDiv = null;
if(data[index].next){
let next= createTreeDate(data[index].next);
childrenDiv=<div onClick={clickMod()}>{next}</div>;
}
let li = <li style={styleName()} key={index}>
<div>{data[index].name}</div>
{childrenDiv}
</li>;
lis.push(li);
}
return <ul>{lis}</ul>
}
}
let treeHtml =createTreeDate(data); return ( <div> {treeHtml} </div> )