后台数据json格式为:
<script src="http://www.jq22.com/jquery/2.1.1/jquery.min.js"></script>
<script src="js/bootstrap-treeview.js"></script>
<script type="text/javascript">
$(function() {
var defaultData = [
{
text: '张三',
tags: ['1'],//信息数
nodes: [
{
text: '张三01',
tags: ['0'],
nodes: [
{
text: '张三001',
tags: ['1']
},
{
text: '张三002',
tags: ['11']
}
]
},
]
},
{
text: '李四',
href: '#parent2',
tags: ['0']
},
];
$('#treeview6').treeview({
color: "#428bca",
expandIcon: "glyphicon glyphicon-stop",
collapseIcon: "glyphicon glyphicon-unchecked",
nodeIcon: "glyphicon glyphicon-user",
showTags: true,
data: defaultData
});
});
</script>
- 前端显示树
- js代码ajax
- 在bootstrap-treeview.js 上为树项加点击事件
- 后台返回数据
- 拼接json格式数据
----------------小白记录不喜勿喷