// 定义一个函数来遍历树形数据并设置节点的checked、半选和disabled状态 setNodeStates(nodes, selectedIds) { const treeRef = this.$refs["from-tree"]; // 获取 vue-easy-tree 的引用 if (treeRef) { nodes.forEach(node => { const isSelected = selectedIds.includes(node.id); // 设置节点勾选状态 treeRef.setCheckedKeys(selectedIds) //处理半选 node.disabled = isSelected; if (node.children && node.children.length > 0) { this.setNodeStates(node.children, selectedIds); } }); } else { console.error("Tree reference not found!"); } },
<vue-easy-tree :ref="treeId" v-loading="loading" :show-checkbox="show" :expand-on-click-node="false" :props="treeProps" :data="treeData_self" highlight-current :node-key="treeNodeKey" height="300px" :check-strictly="strictly" :filter-node-method="filterNode" @onNodeDbClick="onNodeDbClick"> <span slot-scope="{ node, data }" class="custom-tree-node"> <div class="label-content"> <span :title="showTreeLabelName(data)">{{ showTreeLabelName(data) }}</span> </div> </span> </vue-easy-tree>
虚拟滚动 主要是设置node-key 和 height属性
标签:node,vue,tree,treeRef,selectedIds,easy,children From: https://www.cnblogs.com/yanni-w/p/18670962