var data=[
{ID: "1", PId: "0", Name: "大类1"},
{ID: "2", PId: "1", Name: "小类a"},
{ID: "3", PId: "1", Name: "小类b"},
{ID: "4", PId: "1", Name: "小类c"},
{ID: "5", PId: "0", Name: "大类2"},
{ID: "6", PId: "5", Name: "小类1"},
{ID: "7", PId: "5", Name: "小类2"},
{ID: "8", PId: "5", Name: "小类3"},
]
页面上有个
<div id="content"></div>
希望使用
求怎么循环数组拼接,让页面div变成需求的这样父子关系div,如下
<div class="layui-tab">
<ul class="layui-tab-title">
<li class="layui-this">大类1</li>
<li>大类2</li>
<li>大类3</li>
<li>大类...</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">小类a,小类b,小类c</div>
<div class="layui-tab-item"> 小类1,小类2,小类3</div>
<div class="layui-tab-item">大类3的子菜单内容</div>
<div class="layui-tab-item">对于大类下子菜单内容...</div>
</div>
</div>