1.0.2 • Published 3 years ago

light-vue-tree v1.0.2

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

Tree component based on Vue implementation

  • Support drag, check, multiple check, bigData virtual scroll, lazy load, checkStrictly, add and delete node, etc.

Simple usage

 npm install light-vue-tree
<template>
    <div class="base">
        <VueTree
        ref="tree1"
        draggable
        :treeData="treeData"
        @on-drop="dropNode"
        @on-selected-change="clickNode"
        />
    </div>
</template>
<script>
import { treeData } from '../../assets/treeData'
export default {
    name: 'Base',
    data () {
        return {
            treeData
        }
    },
    methods: {
        dropNode({ parentNode, targetNode, callback }) {
            console.log("dropNode", parentNode, targetNode);
            callback(targetNode);
        },
        clickNode (node) {
            console.log('clickNode', node)
        }
    }
}
</script>

Screenshots

Virtual tree render big data (100000 node):

checkbox:

Advantages

  • Simple and very easy to use.

  • Big data list with high render performance and efficient.

  • Can Customize following components (e.g. checkbox, expand icon, loading)

Api

props

PropertyTypeDescriptionDefault
treeDataArrayObjectThe treeNodes data Array,if set it then you need not to construct children TreeNode.(key should be unique across the whole array)-
showCheckboxbooleanAdd a Checkbox before the treeNodesfalse
draggablebooleanWhether to allow dropping on the nodefalse
checkStrictlybooleanCheck treeNode precisely; parent treeNode and children treeNodes are not associatedfalse
lazybooleanLazy load node datafalse
loadfunctionLoad data asynchronouslyfunction(node)-
immediatelyLoadbooleanFirst load data when lazy loadfalse
virtualbooleanDisable virtual scroll when set to falsefalse
heightnumberWhen virtual scroll must set-
expandedAllbooleanWhether to expand all treeNodes by default-
keepsnumberHow many items you are expecting the virtual list to keep rendering in the real dom.30
searchValStringSearch keywords-

Events

PropertyTypeDescriptionParams
on-selected-changefunctionCallback function for when the user right clicks a treeNodefunction(node)
on-dropfunctionCallback function for when the user drag nodefunction({ parentNode, targetNode, callback })
on-checked-itemfunctionCallback function for when the user check nodefunction({ node, vNode })
on-checked-changefunctionCallback function for when checkbox changefunction({ node, selectedData })

Scoped Slot

nameDescription
loadingcustomize loading component, params({loading})
checkcustomize check component, params({handleClickCheckBox, selectToggle, node})
expandIconcustomize expand icon and unexpanded icon, params({ expanded, toggleFold })

Contributions

Welcome to improve this component with any issue, pull request or code review.

License

MIT License.

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.1

3 years ago