TreeData(html){
}
请在TreeData函数里写下答案,不能使用浏览器API
TreeData(`<html>
<head>
<title></title>
</head>
<body>
<div id="container">
<p>hello</p>
<p></p>
<p></p>
</div>
</body>
</html>`)
TreeData函数的输出如下:
{
tags: "html",
children: [{
tags:"head",
children: [{
tags:"title",
},
{
tags:"body",
children: [{
tags:"div",
children:[{
tags:"p"
},{
tags:"p"
},{
tags:"p"
}]
},
}
]
}]
}
百度和谷歌可以找到都是获取Dom树,但是我是传一段字符串过去,想了好久还是没想到,有大佬找到的吗?