0.1.3 • Published 3 years ago

vue-virtual-scroll-tree v0.1.3

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

Vue Virtual Scroll Tree

js 3 + Virtual Scroll + Tree

Install

npm install --save vue-virtual-scroll-tree

Quick Start

import Vue from 'vue'
import VueVirtualScrollTree from 'vue-virtual-scroll-tree'

Vue.use(VueVirtualScrollTree)

// or
import { VueVirtualScrollTree } from 'vue-virtual-scroll-tree'

Vue.component(VueVirtualScrollTree.name, VueVirtualScrollTree)

Basic Usage

<template>
  <VueVirtualScrollTree :data="treeData">
    <template v-slot="{ item }">
      <span>{{ item.label }}</span>
    </template>
  </VueVirtualScrollTree>
</template>

<script>
export default {
  data () {
    return {
      treeData: [
        {
          label: 'Level one 1',
          children: [
            {
              label: 'Level two 1-1',
              children: [
                {
                  label: 'Level three 1-1-1'
                }
              ]
            },
            {
              label: 'Level two 1-2'
            }
          ]
        },
        {
          label: 'Level one 2'
        }
      ]
    }
  }
}
</script>

Build

npm run build

Attributes

AttributeDescriptionTypeDefault
datatree dataarray[]
empty-texttext displayed when data is voidstringNo Data
highlight-currentwhether current node is highlightedbooleantrue
default-expand-allwhether to expand all nodes by defaultbooleantrue
showIconshows the icon before a node's label.booleantrue
showLineshows a connecting linebooleantrue
filter-node-methodthis function will be executed on each node when use filter method. if return false, tree node will be hidden.Function(value, data)
timeoutrefresh timeoutnumber17
optionconfiguration options, see the following tableobject

Option

AttributeDescriptionTypeDefault
heightconfig virtual scroll height.number500
itemHeightconfig node's height.number24

Node props

AttributeDescriptionType
labelnode's labelstring
childrennode's subtreestring
disableddisables the nodeboolean

Method

MethodDescriptionParameters
filterfilter all tree nodes, filtered nodes will be hiddenAccept a parameter which will be used as first parameter for filter-node-method

Events

Event NameDescriptionParameters
node-clicktriggers when a node is clickednode object corresponding to the node clicked

Scoped Slot

NameDescription
Custom content for tree nodes. The scope parameter is { item }