JavaScript如何使用dhtmlXTreeObject的loadJSONObject繪制目錄樹(shù)
1,引入dhtmlXTreeObject的css和js文件
注意: js的引用順序很關(guān)鍵?。。?/p>

2,創(chuàng)建一棵目錄樹(shù)
2.1,let tree = new dhtmlXTreeObject(id-dhtmltree-0, “100%”, “100%”, 0);
2.2,設(shè)置圖片根目錄(后續(xù)使用到的圖片都是相對(duì)于該目錄的)
tree.setImagePath("/common/dhtmlxTree/imgs/");

3,代碼
let tree = new dhtmlXTreeObject(`id-dhtmltree-${this.groupId}`, "100%", "100%", 0);
tree.setImagePath("/common/dhtmlxTree/imgs/");
//tree.enableCheckBoxes(1);
let jsonobj = {
id:0,
item:[
{
id:1,
text:"root",
im0:"common/dhtmlxtree_icon.gif",
im1:"common/dhtmlxtree_icon.gif",
im2:"common/dhtmlxtree_icon.gif",
item:[
{id:2,text:"first"},
{id:3, text:"middle",
item:[
{id:"31", text:"child"}
]},
{id:4,text:"last"}
]
}
]
}
console.log(tree)
tree.loadJSONObject(jsonobj, function(){
console.log("load json to tree success!")
});到此這篇關(guān)于jsvascript使用dhtmlXTreeObject的loadJSONObject繪制目錄樹(shù)的文章就介紹到這了,更多相關(guān)js dhtmlXTreeObject目錄樹(shù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
JS獲取時(shí)間的相關(guān)函數(shù)及時(shí)間戳與時(shí)間日期之間的轉(zhuǎn)換
JavaScript仿淘寶頁(yè)面圖片滾動(dòng)加載及刷新回頂部的方法解析

