1楼
首先 这是我返回的json
[{"id":"4028a211344fdd1701344ff941360007","open":"true","name":"左侧菜单","isParent":"true","pid":""},{"id":"4028a211341bc98501341bca5ec30001","open":"true","name":"权限管理","isParent":"true","pid":"4028a211344fdd1701344ff941360007"},{"id":"4028a211341bce4c01341bd192b20001","open":"true","name":"用户管理","isParent":"true","pid":"4028a211344fdd1701344ff941360007"},{"id":"4028a211341c7b3e01341c8060350001","open":"true","name":"新建","pid":"4028a211341bce4c01341bd192b20001"},{"id":"4028a211341c4d3701341c52d0e00001","open":"true","name":"角色管理","isParent":"true","pid":"4028a211344fdd1701344ff941360007"},{"id":"4b9c6819236c43b397753adea195dcd4","open":"true","name":"顶部菜单","isParent":"true","pid":""},{"id":"4028a211341c61ba01341c63086d0001","open":"true","name":"规则设置","isParent":"true","pid":"4b9c6819236c43b397753adea195dcd4"}]
我没有采用异步加载。
这是我页面调用的代码
var zTree;
var setting = {
isSimpleData : true,
showIcon : false,
open :true,
treeNodeKey : "id", //在isSimpleData格式下,当前节点id属性
treeNodeParentKey : "pid", //在isSimpleData格式下,当前节点的父节点id属性
showLine : true, //是否显示节点间的连线
checkable : true, //每个节点上是否显示 CheckBox
callback : {
}
};
function showParentDiv () {
$("#parentDiv").show();
$("#parentDiv").height(parseFloat($(".addtableInfo").height())-22);
$.ajax({
url: '${ctx}/sysmgmtRole/roleInfo!preSetRole.action',
success: function(data){
var treeNodes = data;
zTree = $("#tree").zTree(setting, treeNodes);
}
});
}
报错如下:
node[setting.nameCol] is undefinedappendTreeNodes()jquery...-2.6.js (第 398 行)setting = Object { treeObjId="tree", treeObj=[1], checkable=true, 更多...}level = 0treeNodes = ["[{"id":"4028a211344fdd1...43b397753adea195dcd4"}]"]parentNode = undefined
请高人告诉我这是什么原因。。 我实在不知道这是什么原因。