0.1.35 • Published 3 years ago

@qhh/vue3-virtual-tree v0.1.35

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

#虚拟树 使用 Vue 3 + Typescript + Vite

安装

  • npm i @qhh/vue3-virtual-tree

使用

  • import { VirtualTree } from '@qhh/vue3-virtual-tree'
  • import '@qhh/vue3-virtual-tree/dist/style.css'

node 节点样例

{
  id: 0,
  label: '全部',
  parentId: null, // 根节点的 parentId 必须为 null
  disabled: false, // 可选
  children: [
    {
      id: 1,
      label: '全部',
      parentId: 0, // 根节点的 parentId 必须为 null
      disabled: false, // 可选
      children: null
    }
  ]
}

Attributes

参数说明类型可选值默认值
options树形结构默认为{label: 'label', childrenKey: 'children', parentIdKey: 'parentId', idKey: 'id'}Object:-----:-----
hasInput是否含有过滤输入框,输入框过滤支持多个关键词,逗号隔开(中英都可以),eg: '位置 1,位置 2,位置 3'Boolean--false
customSearch自定义搜索块,配合searchKeywordBoolean--false
配合searchKeywordv-model绑定值 , 用于搜索String--''
placeholder过滤输入框的 placeholder,配合 hasInput 使用String--请输入关键字进行查找
indent缩进String, Number--15
expandLevel展开程度String, Number'all',1,2,3,,,'all'
expandKeys指定 id 展开, 若指定 id 展开,则 expandLevel 失效Array[]
isLoading是否展示'加载中...'指示状态Boolean--false
checkedAction操作 label 执行选中String'none': 不选中;'click': 单击选中;'dblclick': 双击选中'none'
emptyText内容为空展示的文本String--暂无数据
showCheckbox是否展示 checkboxBoolean--false
showCheckboxLeafOnly是否仅叶子节点展示 checkbox, 配合 showCheckbox = true 才有效。Boolean--false
defaultCheckedKeys默认选中, SetData 之后赋值。Array--[]
checkStrictly在显示复选框的情况下,是否严格的遵循父子不互相关联的做法Boolean--false

方法

方法名称说明参数
SetData设置treetree(Array 类型)
setCheckedKeys回显选中状态id 组成的数组
setCheckedNodes回显选中状态node 节点组成的数组
getCheckedKeys返回id 组成的数组--
getCheckedNodes返回 node 节点组成的数组--
clearChecked清空所有选中--
setExpand指定 id 展开id 组成的数组
showCheckedOnly只展示选中的项,此方法会置空过滤条件isOnlyInCheckedSearch, 是否只在选中的节点里进行筛选, 默认 true
restore对 showCheckedOnly 之后进行恢复--
update手动更新选中状态--
clear清空内存占用--

Events

事件名称说明回调参数
onChange选中状态变化触发({ checkedKeys, checkedNodes })
onClickLabel点击 label 触发node
onClickCheckbox点击 checkbox 触发, 获取当前点击的节点node

Scoped Slot

name说明
defaultlabel 的 slot, eg: <template #default="{ slotScope }"><span><i>&#9733;</i> {{ slotScope.label }}</span></template>
preInputinput 输入框前的 slot, eg: <template #preInput><span>https://</span></template>
loading自定义加载中 slot, eg: <template #loading><i>加载中...</i></template>
expandIcon自定义展开图标 slot, eg: <template #expandIcon><img src="test.jpg" /></template>
0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.30

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.27

3 years ago

0.1.29

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.16

3 years ago

0.1.8

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.0.1

3 years ago