gpt4 book ai didi

javascript - DynaTree 根节点 null/undefined - children undefined

转载 作者:行者123 更新时间:2023-11-30 07:46:52 25 4
gpt4 key购买 nike

("#tree").dynatree({                
minExpandLevel: 1,
//persist: true,
children: [{"title":"First Location",
"isFolder":true,
"expand":true,
"key":"location.92",
"icon":"location.gif",
"children":[{"title":"<span class='assetType'>First Location Child<\/span>",
"key":"locationid=92&typeid=1",
"expand":true,
"icon":"equipment.gif",
"children":[ (etc...)

我也是这样的:

var rootNode = $("#tree").dynatree("getRoot");
var title = rootNode.data.title;

title = null

...好的,所以我试试:

var rootNode = $("#tree").dynatree("getRoot");
var node = rootNode.getChildren();
var title = node.data.title;

无法读取未定义的属性“标题”

如果我只是:

alert(node);

我得到:

DynaTreeNode : '第一个位置'

那么……?

既然我在问,在控制台中:

jquery.dynatree.min.js:710:49:53.215 - Option 'title' is no longer supported.

?

相关?

Uncaught TypeError: Cannot read property 'parentNode' of null
ra

最佳答案

rootNode 是(不可见的)系统根并且未设置 rootNode.data.title。由于 node.getChildren() 返回一个列表,所以它应该是

var rootNode = $("#tree").dynatree("getRoot");
var nodeList = rootNode.getChildren();
var title = nodeList[0].data.title;

关于javascript - DynaTree 根节点 null/undefined - children undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4564049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com