5.0.3 • Published 2 years ago

tj-virtualized-tree v5.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

tj-virtualized-tree

一个用 Vue3 写的虚拟化树形组件, 当数据量大时使用它会比较流畅。

安装

> npm i tj-virtualized-tree

> yarn add tj-virtualized-tree

> pnpm add tj-virtualized-tree

基础用法

<template>
  <TJVirtualizedTree :data="treeData" />
</template>

<script lang="ts" setup>
import TJVirtualizedTree from 'tj-virtualized-tree';

const treeData = [
  {
    id: 'node-1',
    label: 'node-1',
    children: [
      {
        id: 'node-1-1',
        label: 'node-1-1',
      },
    ],
  },
  {
    id: 'node-2',
    label: 'node-2',
    children: [
      {
        id: 'node-2-1',
        label: 'node-2-1',
      },
    ],
  },
  {
    id: 'node-3',
    label: 'node-3',
    children: [
      {
        id: 'node-3-1',
        label: 'node-3-1',
      },
    ],
  },
  {
    id: 'node-4',
    label: 'node-4',
    children: [
      {
        id: 'node-4-1',
        label: 'node-4-1',
      },
    ],
  },
];
</script>

Props

属性说明类型默认值
data虚拟树展示的数据TreeData[]-
visibleCount可视区域的元素数量number-
itemSize元素高度number30
defaultExpandedKeys默认展开项的 id 数组string[][]
defaultCheckedKeys默认选中项的 id 数组string[][]
showCheckbox是否显示复选框booleanfalse
emptyText空提示stringNo Data
checkStrictly在显示复选框的情况下,是否严格的遵循父子不互相关联的做法booleanfalse
indent相邻级节点间的水平缩进, 单位为像素number15
props配置节点信息object{ value: 'id', label: 'label', children: 'children'}
load懒加载子节点, 回调 resolve 函数, 传递子节点数据, 实现懒加载子节点(node, resolve) => void-

当使用懒加载时,需要给数据增加一个 loading 字段, 这个字段为 true 则代表该节点下存在子节点,可以进行懒加载,为 false 代表该节点下没有子节点,这时就不会展示展开 icon,也不会触发懒加载。

TreeData

属性说明类型
id节点唯一标识string
label节点标签展示值string
children子节点数组TreeData[]

Events

事件名说明参数
node-expand节点展开时触发node
node-collapse节点折叠时触发node
check复选框被点击的时候触发(node, checked)
node-click节点点击时触发(node, event)
node-contextmenu节点右击触发(node, event)

Methods

方法名说明参数
getCheckedKeys获取选中节点的 id 数组-
getHalfCheckedKeys获取半选中节点的 id 数组-
setData设置 tree 数据nodes 新节点数组
setExpandedKeys设置展开节点keys 展开节点 id 数组
setCheckedKeys设置选中节点keys 选中节点 id 数组
insertSiblingNodes插入节点key: 参照节点 id, nodes: 插入节点数组

Slots

插槽说明参数
default默认插槽, 用于自定义渲染节点node 节点信息
icon自定义节点的 icon 图标-
empty空提示插槽-
5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

3.4.2

2 years ago

3.5.0

2 years ago

3.4.1

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago

3.4.0

2 years ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago