下面的代码如何利用fox的行政表内数据,生成动态目录树并给到前断调用
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>测试页面</title>
<link rel="stylesheet" href="./../../layui/css/layui.css">
<script src="./../../layui/layui.all.js"></script>
</head>
<body>
<div id="test"></div>
<script>
var $ = layui.$;
var dt = [{
title: '一线城市',
id:1,
spread:true,
checked:true,
children: [{
title: '北京市',
id:'bj',
children: [{
title: '东城区',
id:'dc'
},{
title: '西城区'
},{
title: '朝阳区'
},{
title: '海淀区'
}]},{
title: '上海市',
id:'sh'
},{
title: '广州市'
},{
title: '深圳市'
}]
},{
title: '二线城市',
id:2,
children: [{
title: '南京市'
},{
title: '杭州市'
},{
title: '成都市'
},{
title: '武汉市',
disabled:true
}]
}];
var tr = layui.tree;
tr.render({
elem: '#test', //绑定的元素对象
data: dt, //绑定dt变量到data属性
});
</script>
</body>
</html>