zTree默认选中根节点,默认展开

let treeObj = $.fn.zTree.init($("#tree"), setting, departments);

treeObj.expandAll(true);    //默认展开
        
var nodes = treeObj.getNodes();  
if (nodes.length > 0) {
    var node = treeObj.selectNode(nodes[0]);//默认选中根节点
}

你可能感兴趣的:(前端)