jsvascript使用dhtmlXTreeObject的loadJSONObject绘制目录树

文章目录

1,引入dhtmlXTreeObject的css和js文件

注意: js的引用顺序很关键!!!

2,创建一棵目录树

2.1,let tree = new dhtmlXTreeObject(id-dhtmltree-0, "100%", "100%", 0);

2.2,设置图片根目录(后续使用到的图片都是相对于该目录的)

复制代码
tree.setImagePath("/common/dhtmlxTree/imgs/");


3,代码

javascript 复制代码
            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!")
            });
相关推荐
bjzhang75几秒前
使用 HTML + JavaScript 实现可编辑表格
前端·javascript·html
GDAL3 分钟前
js的markdown js库对比分析
javascript·markdown
指尖跳动的光3 分钟前
js如何判空?
前端·javascript
石像鬼₧魂石11 分钟前
Fail2ban + Nginx/Apache 防 Web 暴力破解配置清单
前端·nginx·apache
梦65011 分钟前
基于Umi 框架(Ant Design Pro 底层框架)的动态路由权限控制实现方案
前端·react
weixin_464307631 小时前
设置程序自启动
前端
小满zs1 小时前
Next.js第十七章(Script脚本)
前端·next.js
小满zs2 小时前
Next.js第十六章(font字体)
前端·next.js
喝拿铁写前端7 小时前
别再让 AI 直接写页面了:一种更稳的中后台开发方式
前端·人工智能