怎么用JavaScript或css在thinkPHP的模板中显示树形结构

WBOY
Release: 2016-06-20 12:32:59
Original
917 people have browsed it

后台的数据是这样子的

array(2) {  [0] => array(4) {    ["pid"] => string(1) "0"    ["id"] => string(1) "1"    ["name"] => string(9) "江西省"    ["son"] => array(2) {      [0] => array(3) {        ["pid"] => string(1) "1"        ["id"] => string(1) "2"        ["name"] => string(9) "南昌市"      }      [1] => array(4) {        ["pid"] => string(1) "1"        ["id"] => string(1) "3"        ["name"] => string(9) "赣州市"        ["son"] => array(1) {          [0] => array(3) {            ["pid"] => string(1) "3"            ["id"] => string(1) "4"            ["name"] => string(9) "大田乡"          }        }      }    }  }  [1] => array(4) {    ["pid"] => string(1) "0"    ["id"] => string(1) "6"    ["name"] => string(12) "黑龙江省"    ["son"] => array(1) {      [0] => array(3) {        ["pid"] => string(1) "6"        ["id"] => string(1) "5"        ["name"] => string(12) "哈尔滨市"      }    }  }}
Copy after login

怎么在前台输出来,数据有可能会变化。换句话说不能写死样式。求指导


回复讨论(解决方案)

你是写css 还是写tp的标签啊 ?这个树有几层 也是未知的嘛 tp模版就volist标签 然后判断是否有son,有son是一种样式 没有son是另外一种样式

tp的标签能提供一下代码么

首先你要循环  就用volist  foreach 都可以  判断就用  if 就行了 手册上面有 百度就知道了 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template