Skip to content

TreeView-DEMO ​


vue
<fv-TreeView v-model="files" style="width:200px" :viewStyle="{backgroundColor:'transparent'}" background="transparent">
</fv-TreeView>

TreeView Draggable ​


vue
<fv-TreeView v-model="files" :draggable="true" @click="click" @drop-item="dropItem">
</fv-TreeView>
javascript
dropItem (event) {
    let { root, drop, dropParent, drag, dragParent, mode } = event;
    if (mode === 'enter') {
        if(!drop.children)
            drop.children = [];
        drop.children.push(drag);
        let dragParentChildren = dragParent ? dragParent.children : root;
        dragParentChildren.splice(dragParentChildren.indexOf(drag), 1);
    } else {
        let dropParentChildren = dropParent ? dropParent.children : root;
        const index = dropParentChildren.indexOf(drop);
        dropParentChildren.splice(index, 0, drag);
        let dragParentChildren = dragParent ? dragParent.children : root;
        dragParentChildren.splice(dragParentChildren.indexOf(drag), 1);
    }
}

TreeView Checkable ​


vue
<fv-TreeView v-model="files" :checkable="true" expandedIconPosition="right" @click="click">
</fv-TreeView>

Slots ​

vue
<fv-TreeView v-model="files" style="width:200px">
  <template v-slot:default="prop">
    {{prop.item.label}}
  </template>
</fv-TreeView>

TreeView Customize and Draggable ​


backgroundColorHover:

backgroundColorActive:

foregroundColor:
vue
<fv-TreeView
  :theme="$theme" 
  v-model="files" 
  :checkable="true" 
  @click="click" 
  :backgroundColorHover="backgroundColorHover"
  :backgroundColorActive="backgroundColorActive"
  leftIconForeground="black"
  :foreground="foregroundColor"
  :draggable="true" 
  expandClickMode="normal"
  :space="10">
</fv-TreeView>

Properties ​


PropertyTypeRequiredDefaultDescription
modelValuearrayNo[]Data. See the data section for details.
draggablebooleanNofalseWhether items are draggable.
checkablebooleanNofalseWhether items are checkable.
spacenumberNo20See the TreeView space option.
foregroundstringNo'rgba(0, 90, 158, 1)'Foreground color.
expandedIconstringNo'ChevronDownSmall'See the TreeView expandedIcon option.
unexpandedIconstringNo'ChevronRightSmall'See the TreeView unexpandedIcon option.
expanderIconColorstringNo''Expander icon color.
backgroundColorHoverstringNo''See the TreeView backgroundColorHover option.
backgroundColorActivestringNo''See the TreeView backgroundColorActive option.
itemHeightnumberNo30Item height.
showLoadingbooleanNofalseWhether to show a progress indicator while loading.
expandedIconPositionstringNo'left'Expand arrow position.
expandClickModestringNo'normal'Expand trigger mode.
themestringNo'global'Theme color.
disabledbooleanNofalseSee the TreeView disabled option.
langstringNo"global"See the TreeView lang option.

Events ​


EventArgumentsDescription
clickitemEmitted when an item is clicked. The first argument is the clicked item.
drop-item{root, drop, dropParent, drag, dragParent, mode}See the component drop-item option.
item-drag-over{root, drop, dropParent}Emitted when the dragged item enters the current item.
item-drag-leave{root, drop, dropParent}Emitted when the dragged item leaves the current item.
item-drop{root, drop, dropParent}Emitted when an item is dropped on the current item.

Slotss ​


  1. TreeItem
vue
<template v-slot:default="x">
  {{x.item.label}}
</template>

Data ​


  1. value
javascript
value = [{label: '', icon: '', disabled: '', children: [], expanded: false, selected: false, loading: false, dropInside: true, show: true}]

[
    {
        label: 'Img Folder',
        icon: 'https://img.icons8.com/bubbles/2x/folder-invoices.png',
        children: [
            {
                label: 'Folder',
                icon: 'Folder',
                expanded: true,
                children: [
                    {
                        label: 'File',
                        icon: 'FileCode'
                    },
                    {
                        label: 'File',
                        icon: 'FileCode'
                    }
                ]
            },
            {
                label: 'File',
                icon: 'FileCode'
            },
            {
                label: 'File',
                icon: 'FileCode',
                disabled: true
            },
            {
                label: 'No Drop Inside',
                icon: 'Error',
                dropInside: false
            }
        ]
    },
    {
        label: 'File',
        icon: 'FileCode'
    },
    {
        label: 'Cascade',
        icon: 'https://img.icons8.com/bubbles/2x/folder-invoices.png',
        children: [
            {
                label: 'Cascade2',
                icon: 'Folder',
                children: [
                    {
                        label: 'Cascade3',
                        icon: 'FileCode',
                        children: [

                        ]
                    },
                    {
                        label: 'File',
                        icon: 'FileCode',
                        disabled: true
                    }
                ]
            }
        ]
    }
]

MIT Licensed