• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
丶菜鸟也会飞
博客园    首页    新随笔    联系   管理    订阅  订阅
vue-easy-tree解决大量数据卡死问题 虚拟滚动
            // 定义一个函数来遍历树形数据并设置节点的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属性

posted on 2025-01-14 15:50  丶菜鸟也要飞  阅读(541)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3