前端 cateTree.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="layout :: htmlhead" th:with="title='角色管理'"></head>
<link rel="stylesheet" th:href="@{/layui/css/layui.css}"></link>
<script th:src="@{/layui/layui.js}"></script>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
<div class="layui-body" style="margin: 1%">
<div id="test13" class="demo-tree-more"></div>
</div>
<script th:src="@{/js/myTree.js}"></script>
</div>
</body>
</html>
前端 myTree.js
$(function() {
getData();
})
function getData(){
$.ajax({
type: "get",
data: "id=0",
url: "/category/findCategoryJson",
success: function (data) {
layui.use(['tree', 'util'], function() {
var tree = layui.tree
, layer = layui.layer
, util = layui.util
//无连接线风格
tree.render({
elem: '#test13'
,data: data