0.8.3 • Published 3 years ago

@qhh/vue2-virtual-tree v0.8.3

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

#虚拟树

安装

  • npm i @qhh/vue2-virtual-tree

使用

  • import { VirtualTree } from '@qhh/vue2-virtual-tree'
  • import '@qhh/vue2-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

参数说明类型可选值默认值
itemHeight每项的高度 (必填)Number:-----------
options树形结构默认为{labelKey: 'label',labelExtendKey: null, childrenKey: 'children', idKey: 'id', extendCountKey: null, disabledKey: 'disabled'} labelKey: 显示的文本字段,labelExtendKey: 如果自定义的父级结构和leaf结构不一样, 则使用此值 扩展搜索, childrenKey: 子级的字段, idKey: id字段, extendCountKey: 额外的显示数量字段. 如: 需要显示在线数 节点在线字段为online: true, 则此值为'online'. 注: 此处只能显示默认为true 的字段, 如需离线数, 节点需新增字段 offline: true, disabledKey: 禁用的字段名Object:-----{childrenKey: 'children',labelKey: 'label',labelExtendKey: null, idKey: 'id', extendCountKey: null,disabledKey: 'disabled'}
countOptions树形结构默认为{computed: false, showCount: false, filter: false, extendCount: []} showCount: 计算count, showCount: 显示count, filter: 数据是基于原数据还是过滤后的数据, extendCount: 默认只计算叶子节点的数量额外的显示数量字段. 如需要显示字段为online值为true, 则该值为{key: 'online':value:true}此处使用全等于 ,请保持数据类型一致Object:-----{ showCount: false,computed: false,filter: false, extendCount: []}
checkboxOptions树形结构默认为{showCheckbox: false,showCheckboxLeafOnly: false,showCheckboxByKeys: null,preCheckbox: true, checkBoxSize: '12px',checkedIcon: defaultCheckedIcon,checkedPartIcon: defaultCheckedPartIcon, checkedDisabledIcon: defaultCheckedDisabledIcon,checkedPartDisabledIcon: defaultCheckedPartDisabledIcon} showCheckbox: 是否显示,showCheckboxLeafOnly: 是否只显示叶子节点,showCheckboxByKeys: 对象有keys值中的一个才会显示,preCheckbox: 位置前置, checkBoxSize: 大小,checkedIcon: 选中的icon,checkedPartIcon: 部分选中的icon, checkedDisabledIcon: 禁用时选中的icon ,checkedPartDisabledIcon: 禁用时半选中的iconObject:-----{showCheckbox: false,showCheckboxLeafOnly: false,showCheckboxByKeys: null,preCheckbox: true, checkBoxSize: '12px',checkedIcon: defaultCheckedIcon,checkedPartIcon: defaultCheckedPartIcon, checkedDisabledIcon: defaultCheckedDisabledIcon,checkedPartDisabledIcon: defaultCheckedPartDisabledIcon}
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[]
expandIcon自定义展开图标String---
foldIcon自定义折叠图标String---
isLoading是否展示'加载中...'指示状态Boolean--false
checkedAction操作 label 执行选中String'none': 不选中;'click': 单击选中;'dblclick': 双击选中'none'
emptyText内容为空展示的文本String--暂无数据
defaultCheckedKeys默认选中, setData 之后赋值。Array--[]
checkStrictly在显示复选框的情况下,是否严格的遵循父子不互相关联的做法Boolean--false
checkBoxSize选择框的大小, 默认同时影响expand box的尺寸 ,除非自定义expandIcon的slotString---12px
preCheckboxcheckBox 是否前置(在左侧 而非右侧)Boolean---true
expandRotate展开图标动画旋转的角度Number---180
labelClass自定义label的样式String---''
itemClass自定义item的样式String---''
extendFilter扩展的过滤条件 以{key1: value1, key2:value2 ...}, {...}形式传入 会根据key和value过滤对象,数组内为并且, 对象内为或者Object---null(不过滤)
cacheCount缓存数Number---50
throttleScrollTime滚动触发的节流时间Number---80
overflowX横向滚动条Boolean---true

方法

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

Events

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

Scoped Slot

name说明
defaultlabel 的 slot, eg: <template #default="{ item }"><span><i>&#9733;</i> {{ item.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={ expand }><img v-if='expand' src="expand.jpg" /><img v-else src='flod.jpg' /></template>
customSearch自定义搜索部分 具体例子如下:

customSearch:

<!--search为搜索事件, 把keyword传入-->
<!--reset为 清空搜索事件 ,本页的keyword需自己清空!-->
<template #customSearch="{ search, reset }">
  <div class="input">
    <label>
      <input
        type="text"
        class="filter-input"
        placeholder="请输入"
        v-model="keyword"
      />
    </label>
    <i
      class="clear-input"
      v-if="keyword"
      @click="reset();keyword = '';"
    ></i>
    <button class="search-btn" @click="search(keyword)">搜索</button>
  </div>
</template>

gitee地址: https://gitee.com/txwscoder/virtual-tree.git

0.7.6

3 years ago

0.7.7

3 years ago

0.8.1

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.5

3 years ago

0.7.1

3 years ago

0.6.5

3 years ago

0.6.4

3 years ago

0.4.8

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.6.3

3 years ago

0.4.5

3 years ago

0.6.2

3 years ago

0.4.4

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.1

3 years ago

0.6.1

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.7

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.2.9

3 years ago

0.1.55

3 years ago

0.1.56

3 years ago

0.1.57

3 years ago

0.1.58

3 years ago

0.2.1

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.8

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.1.52

3 years ago

0.1.53

3 years ago

0.1.50

3 years ago

0.1.51

3 years ago

0.1.47

3 years ago

0.1.48

3 years ago

0.1.44

3 years ago

0.1.45

3 years ago

0.1.46

3 years ago

0.1.43

3 years ago

0.1.35

3 years ago

0.1.37

3 years ago

0.1.41

3 years ago

0.1.42

3 years ago

0.1.40

3 years ago

0.1.38

3 years ago

0.1.39

3 years ago

0.1.30

3 years ago

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.27

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.20

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

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.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.0

3 years ago