---
title: "ligerui Tree 学习 - 20150310"
author: "soft_xiaohui"
date: "2015-03-10T20:56:25Z"
tags: []
categories: ["Web前端"]
slug: "ligerui-tree-20150310"
draft: false
lastmod: "2015-03-10T20:57:09Z"
id: 2191193
url: "https://soft-xiaohui.iteye.com/blog/2191193"
---

# []()[]()1.ligerui  tree 一直不显示。

原因：多了一个 **ligeruiid="tree1"** 属性

&lt;ul id="tree1" class="l-tree" style="width: 266px;" **ligeruiid="tree1"**&gt;&lt;/ul&gt;

 

改成就可以了。

 

&lt;ul id="tree1" class="l-tree" style="width: 266px;" &gt;&lt;/ul&gt;

 

 

加载树的代码为：

$(**function**() {

       $("#tree1").ligerTree({

           nodeWidth : 100,

           checkbox : **false**,

           slide : **false**,

           data : \[{text:’树’}]

       });

    });

 

 

# 2延迟加载树

$("#tree1").ligerTree({

       nodeWidth : 300,

       url : '获取二层树结构url',

       isLeaf : **function**(data) {

           **return** (data.cnum == 0);

       },

       delay : 2,

       checkbox : **true**,

       idFieldName : 'id',

       slide : **false**

    });

 

 

 

 

**url ; isLeaf ;delay** 三个属性配合使用。

url 用于获取初始的树数据，只读取二层树基础数据。

isLeaf:用户判断当前树节点是否有子节点，根据当前树元素的特定属性判断。

Delay : 用于判断从树的第几层开始延迟加载。根节点为0层。

 

上述例子中必须有这三个属性，delay 必须为2 ，否则树不能正确显示。