Maison >développement back-end >tutoriel php >怎么用JavaScript或css在thinkPHP的模板中显示树形结构
后台的数据是这样子的
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) "哈尔滨市" } } }}
你是写css 还是写tp的标签啊 ?这个树有几层 也是未知的嘛 tp模版就volist标签 然后判断是否有son,有son是一种样式 没有son是另外一种样式
tp的标签能提供一下代码么
首先你要循环 就用volist foreach 都可以 判断就用 if 就行了 手册上面有 百度就知道了