在项目里用ztree时遇到一个问题,只有最后一个根节点的子节点显示,其他的子节点都加载不出来!

发布于 2021-12-07 02:35:23 字数 662 浏览 921 评论 8

@zTree 你好,在项目里用ztree时遇到一个问题,只有最后一个根节点的子节点显示,其他的子节点都加载不出来!想跟你请教个问题:jquery.min-2.1.4.js这是项目里的jquery版本!这个要怎么解决啊?

这是引入的js

这是代码

异步加载这样,在zTreeNodes=[]里写死节点数据也是这种效果!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

做个少女永远怀春 2021-12-09 14:31:41

你现在再把这个设置去掉,立刻就出现问题么?? 有点儿不可思议呀

甜柠檬 2021-12-09 14:28:20

是啊 这就是蛋疼的地方,把我的数据放在官方的demo里没问题,把官方demo的数据放在我的项目里有问题,这就肯定不是节点数据的问题了,可能是配置问题或js文件冲突之类的!但是这种问题不好找啊!头都要炸了

海之角 2021-12-09 14:20:49

引用来自“jvquery”的评论

zList=[{"id":1,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":101,"name":"****","pid":1,"checked":"true"}
    ,{"id":102,"name":"****","pid":1,"checked":"true"}
    ,{"id":103,"name":"****","pid":1,"checked":"true"}
    ,{"id":104,"name":"****","pid":1,"checked":"true"}
    ,{"id":105,"name":"****","pid":1,"checked":"true"}
    ,{"id":106,"name":"****","pid":1,"checked":"true"}
    ,{"id":2,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":201,"name":"****","pid":2,"checked":"true"}
    ,{"id":202,"name":"****","pid":2,"checked":"true"}
    ,{"id":3,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":301,"name":"****","pid":3,"checked":"true"}
    ,{"id":4,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":401,"name":"****","pid":4,"checked":"true"}
    ,{"id":402,"name":"****","pid":4,"checked":"true"}
    ,{"id":403,"name":"****","pid":4,"checked":"true"}
    ,{"id":5,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":501,"name":"****","pid":5,"checked":"true"}
    ,{"id":502,"name":"****","pid":5,"checked":"true"}
    ,{"id":6,"name":"****","pid":0,"open":"true"}
    ,{"id":601,"name":"****","pid":6}
    ,{"id":602,"name":"****","pid":6}
    ,{"id":7,"name":"****","pid":0,"open":"true"}
    ,{"id":701,"name":"****","pid":7}
    ,{"id":702,"name":"****","pid":7}
    ,{"id":703,"name":"****","pid":7}
    ,{"id":704,"name":"****","pid":7}
    ,{"id":705,"name":"****","pid":7}
    ,{"id":8,"name":"****","pid":0,"open":"true"}
    ,{"id":801,"name":"****","pid":8}
    ,{"id":802,"name":"****","pid":8}
    ,{"id":803,"name":"****","pid":8}
    ,{"id":9,"name":"****","pid":0,"open":"true"}
    ,{"id":901,"name":"****","pid":9}
    ,{"id":902,"name":"****","pid":9}
    ,{"id":903,"name":"****","pid":9}
    ,{"id":10,"name":"****","pid":0,"open":"true"}
    ,{"id":1001,"name":"****","pid":10}
    ,{"id":1002,"name":"****","pid":10}
    ,{"id":11,"name":"****","pid":0,"open":"true"}
    ,{"id":1101,"name":"****","pid":11}
    ,{"id":1102,"name":"****","pid":11}]
这是后台响应的节点数据

居里长安 2021-12-09 14:14:38

zList=[{"id":1,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":101,"name":"****","pid":1,"checked":"true"}
    ,{"id":102,"name":"****","pid":1,"checked":"true"}
    ,{"id":103,"name":"****","pid":1,"checked":"true"}
    ,{"id":104,"name":"****","pid":1,"checked":"true"}
    ,{"id":105,"name":"****","pid":1,"checked":"true"}
    ,{"id":106,"name":"****","pid":1,"checked":"true"}
    ,{"id":2,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":201,"name":"****","pid":2,"checked":"true"}
    ,{"id":202,"name":"****","pid":2,"checked":"true"}
    ,{"id":3,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":301,"name":"****","pid":3,"checked":"true"}
    ,{"id":4,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":401,"name":"****","pid":4,"checked":"true"}
    ,{"id":402,"name":"****","pid":4,"checked":"true"}
    ,{"id":403,"name":"****","pid":4,"checked":"true"}
    ,{"id":5,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":501,"name":"****","pid":5,"checked":"true"}
    ,{"id":502,"name":"****","pid":5,"checked":"true"}
    ,{"id":6,"name":"****","pid":0,"open":"true"}
    ,{"id":601,"name":"****","pid":6}
    ,{"id":602,"name":"****","pid":6}
    ,{"id":7,"name":"****","pid":0,"open":"true"}
    ,{"id":701,"name":"****","pid":7}
    ,{"id":702,"name":"****","pid":7}
    ,{"id":703,"name":"****","pid":7}
    ,{"id":704,"name":"****","pid":7}
    ,{"id":705,"name":"****","pid":7}
    ,{"id":8,"name":"****","pid":0,"open":"true"}
    ,{"id":801,"name":"****","pid":8}
    ,{"id":802,"name":"****","pid":8}
    ,{"id":803,"name":"****","pid":8}
    ,{"id":9,"name":"****","pid":0,"open":"true"}
    ,{"id":901,"name":"****","pid":9}
    ,{"id":902,"name":"****","pid":9}
    ,{"id":903,"name":"****","pid":9}
    ,{"id":10,"name":"****","pid":0,"open":"true"}
    ,{"id":1001,"name":"****","pid":10}
    ,{"id":1002,"name":"****","pid":10}
    ,{"id":11,"name":"****","pid":0,"open":"true"}
    ,{"id":1101,"name":"****","pid":11}
    ,{"id":1102,"name":"****","pid":11}]
这是后台响应的节点数据

一笔一画续写前缘 2021-12-09 13:50:43

你先给ID PID等属性加上双引号“ID“,还是不行你试一下run官方给的网页demo,还不行你换一个浏览器run

猫九 2021-12-09 07:54:41

复制的官方的demo节点数据,效果一样的!

羁拥 2021-12-09 07:18:03

写死的代码贴出来了! 节点数据应该是没问题的,树加载出来之后我获取所以checked的节点id,都能获取到,而且层级关系也没错,就是显示不出来!

甜柠檬 2021-12-07 10:34:05

静态数据? 你是说节点的数据吗?如果是……后台响应的节点数据肯定是没错的

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文