c - 怎么递归渲染树(分类)?
黄舟
黄舟 2017-04-24 09:12:01
0
0
606

Hello.圣诞快乐!

我有个数据结构如下:

0 => 
    array (size=13)
      'id' => string '46' (length=2)
      'name' => string 'Test' (length=9)
      'parent_id' => string '1' (length=1)
      'son' => 
        array (size=2)
          0 => 
            array (size=13)
              ...
          1 => 
            array (size=12)
              ...
  1 => 
    array (size=13)
      'id' => string '914' (length=3)
      'name' => string '测试2' (length=9)
      'parent_id' => string '0' (length=1)
      'son' => 
        array (size=3)
          0 => 
            array (size=12)
              ...
          1 => 
            array (size=12)
              ...
          2 => 
            array (size=12)
              ...
              
              

我怎么绘制一棵树呢?

<li>
                <p class="tree_title">
                    <img src="images/px_02.png" class="icon_btn"/>
                    <label class="title">一级</label>
                    <input type="checkbox" class="view">
                    <input type="checkbox" class="manage">
                </p>

                    <ul class="space">

                        <li>
                            <p class="tree_title">
                                <img src="images/px_02.png" class="icon_btn"/>
                                <lavel class="title">二级</lavel>
                                <input type="checkbox" class="view">
                                <input type="checkbox" class="manage">
                            </p>
                            <ul class="space">
                                <li>
                                    <p class="tree_title">
                                        <img src="images/px_02.png" class="icon_btn"/>
                                        <label class="title">三级</label>
                                        <input type="checkbox" class="view">
                                        <input type="checkbox" class="manage">
                                    </p>
                                </li>
                            </ul>
                        </li>
                    </ul>
            </li>

想了好久没想出来,其中array的son代表它的子节点。。。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

Antworte allen(0)
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage