当前位置: 首页 > news >正文

vue vxe-tree 树组件加载大量节点数据,虚拟滚动的用法

vue vxe-tree 树组件加载大量节点数据,虚拟滚动的用法

查看官网:https://vxeui.com

上万节点数据

在这里插入图片描述

当数据量达到上万时,通过数据双向绑定将会影响性能,可以通过调用 loadData 来加载数据

<template><div><vxe-button status="primary" @click="expandAllEvent">展开所有</vxe-button><vxe-button status="primary" @click="clearAllEvent">关闭所有</vxe-button><vxe-tree ref="treeRef" v-bind="treeOptions"></vxe-tree></div>
</template><script setup>
import { ref, reactive } from 'vue'const treeRef = ref()const treeOptions = reactive({loading: false,height: 400,transform: true,showCheckbox: true,titleField: 'name'
//  默认启用  
//  virtualYConfig: {
//    enabled: true,
//    gt: 0
//  }
})const loadList = () => {treeOptions.loading = truefetch('/resource/json/provinces_list.json').then(res => res.json()).then((data) => {treeOptions.loading = falseconst $tree = treeRef.valueif ($tree) {$tree.loadData(data)}})
}const expandAllEvent = () => {const $tree = treeRef.valueif ($tree) {$tree.setAllExpandNode(true)}
}
const clearAllEvent = () => {const $tree = treeRef.valueif ($tree) {$tree.setAllExpandNode(false)}
}loadList()
</script>

连接线

在这里插入图片描述
在这里插入图片描述

<template><div><vxe-tree :data="treeList" transform show-checkbox show-line></vxe-tree></div>
</template><script setup>
import { ref } from 'vue'const treeList = ref([{ title: '节点2', id: '2', parentId: null },{ title: '节点3', id: '3', parentId: null },{ title: '节点3-1', id: '31', parentId: '3' },{ title: '节点3-2', id: '32', parentId: '3' },{ title: '节点3-2-1', id: '321', parentId: '32' },{ title: '节点3-2-2', id: '322', parentId: '32' },{ title: '节点3-3', id: '33', parentId: '3' },{ title: '节点3-3-1', id: '331', parentId: '33' },{ title: '节点3-3-2', id: '332', parentId: '33' },{ title: '节点3-3-3', id: '333', parentId: '33' },{ title: '节点3-4', id: '34', parentId: '3' },{ title: '节点4', id: '4', parentId: null },{ title: '节点4-1', id: '41', parentId: '4' },{ title: '节点4-1-1', id: '411', parentId: '42' },{ title: '节点4-1-2', id: '412', parentId: '42' },{ title: '节点4-2', id: '42', parentId: '4' },{ title: '节点4-3', id: '43', parentId: '4' },{ title: '节点4-3-1', id: '431', parentId: '43' },{ title: '节点4-3-2', id: '432', parentId: '43' },{ title: '节点5', id: '5', parentId: null }
])
</script>

过滤节点

通过 filter-value 就可以设置过滤功能,通过 filter-config.autoExpandAll 来设置过滤后自动展开与收起
在这里插入图片描述

<template><div><div><vxe-input v-model="treeOptions.filterValue" type="search" clearable></vxe-input></div><vxe-tree v-bind="treeOptions"></vxe-tree></div>
</template><script setup>
import { reactive } from 'vue'const treeOptions = reactive({transform: true,filterValue: '',filterConfig: {autoExpandAll: true},data: [{ title: '节点2', id: '2', parentId: null },{ title: '节点3', id: '3', parentId: null },{ title: '节点3-1', id: '31', parentId: '3' },{ title: '节点3-2', id: '32', parentId: '3' },{ title: '节点3-2-1', id: '321', parentId: '32' },{ title: '节点3-2-2', id: '322', parentId: '32' },{ title: '节点3-3', id: '33', parentId: '3' },{ title: '节点3-3-1', id: '331', parentId: '33' },{ title: '节点3-3-2', id: '332', parentId: '33' },{ title: '节点3-3-3', id: '333', parentId: '33' },{ title: '节点3-4', id: '34', parentId: '3' },{ title: '节点4', id: '4', parentId: null },{ title: '节点4-1', id: '41', parentId: '4' },{ title: '节点4-1-1', id: '411', parentId: '42' },{ title: '节点4-1-2', id: '412', parentId: '42' },{ title: '节点4-2', id: '42', parentId: '4' },{ title: '节点4-3', id: '43', parentId: '4' },{ title: '节点4-3-1', id: '431', parentId: '43' },{ title: '节点4-3-2', id: '432', parentId: '43' },{ title: '节点5', id: '5', parentId: null }]
})
</script>
http://www.dtcms.com/a/279285.html

相关文章:

  • 每日mysql
  • # 检测 COM 服务器在线状态
  • 在Linux下git的使用
  • 7.14练习案例总结
  • 渗透第一次总结
  • ThreadLocal内部结构深度解析(Ⅰ)
  • Olingo分析和实践——整体架构流程
  • idea下无法打开sceneBulider解决方法
  • JavaScript书写基础和基本数据类型
  • 关于僵尸进程
  • SwiftUI 全面介绍与使用指南
  • SSM框架学习——day1
  • 爬虫-爬取豆瓣top250
  • webrtc之子带分割下——SplittingFilter源码分析
  • vscode插件之markdown预览mermaid、markmap、markdown
  • 直播推流技术底层逻辑详解与私有化实现方案-以rmtp rtc hls为例-优雅草卓伊凡
  • 当 `conda list` 里出现两个 pip:一步步拆解并卸载冲突包
  • 2025年轨道交通与导航国际会议(ICRTN 2025)
  • 【数据同化案例1】ETKF求解参数-状态联合估计的同化系统(完整MATLAB实现)
  • C#结构体:值类型的设计艺术与实战指南
  • 2025年新能源与可持续发展国际会议(ICNESD 2025)
  • 非正常申请有这么多好处,为什么还要大力打击?
  • TreeSize Free - windows下硬盘空间管理工具
  • 一分钟K线实时数据数据接口,逐笔明细数据接口,分时成交量数据接口,实时五档委托单数据接口,历史逐笔明细数据接口,历史分时成交量数据接口
  • RESTful API 设计规范
  • 为什么资深C++开发者大部分选vector?揭秘背后的硬核性能真相!
  • Nginx配置信息
  • 项目进度图不直观,如何优化展示方式
  • 一种用于医学图像分割的使用了多尺寸注意力Transformer的混合模型: HyTransMA
  • SecretFlow 隐语 (2) --- 隐语架构概览