0.0.4 • Published 2 years ago

classification-tree v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

classification-tree

English | 简体中文

introduce

This component is based on vue3. It is used to display the tree structure. Each tree node can be customized through slots. The display effect is as follows:
default:
default

custom:
custom

demo

install

$ npm install classification-tree -S

use

<script>
import 'classification-tree/lib/style.css'
import ClassifyTree from 'classification-tree'
import { defineComponent } from 'vue'
export default defineComponent({
	components: {
		ClassifyTree,
	},
  data() {
    return {
      nodeList: [
        {
          label: 'root',
          key: 0,
          slotScope: 'rootNode',
          connectLineOption: {
            showArrow: true,
            lineColor: 'blue',
            lineHeight: '40px',
          },
          children: [
            {
              label: 'node1',
              key: 1,
              connectLineOption: {
                showArrow: true,
              },
              children: [
                {
                  label: 'node11',
                  key: 11,
                  connectLineOption: {
                    lineColor: 'red',
                  },
                },
                {
                  label: 'node12',
                  key: 12,
                  connectLineOption: {
                    lineColor: '#158468',
                  },
                },
                {
                  label: 'node13',
                  key: 13,
                  slotScope: 'newTag',
                  connectLineOption: {
                    lineColor: 'rgba(255, 122, 75, 0.5)',
                  },
                },
              ],
            },
          ],
        },
      ],
      mode: 'vertical'
    }
  }
})
</script>
<template>
	<ClassifyTree :node-list="nodeList" :mode="mode" >
    <template #default="{ node, parent }">
			<div class="classify-item">
        default slot{{ node.label }}
      </div>
    </template>
    <template #rootNode="{ node, parent }">
			<div class="classify-item">
        root node {{ node.label }}
      </div>
    </template>
    <template #newTag="{ node, parent }">
			<div class="classify-item">
        new tag{{ node.label }}
      </div>
    </template>
  </ClassifyTree>
</template>

classification-tree props

propsdescriptiontypedefault
node-listtree node arrayClassificationNode[][]
modeParent-child node arrangement direction'horizon' | 'vertical''vertical'
connectLineOptionConnector display configuration of parent and child nodesConnectLineOption{lineHeight: '20px', showArrow: false, lineColor: 'black', lineWidth: '2'}
treeNodePropsCustom element node object attribute aliasTreeNodeProps{ label: 'label', children: 'children', key: 'key', }
expandExpand button custom slotv-slot:data-
Custom tree node slotsTree node custom slotv-slot: {node, parent}-

ClassificationNode Object

attributedescriptiontypedefault value
labelNode name (can be customized by 'treeNodeProps' prop)string''
keyNode key (can be customized by 'treeNodeProps' prop)string''
childrenNode children (can be customized by 'treeNodeProps' prop)ClassificationNode[]undefined
connectLineOptionConnector display configuration of the nodeConnectLineOptionundefined
styleThe style used for this node divObject{}
classThe class used for this node divstring''
expandedExpand node subarraybooleantrue
slotScopeCustom node slot namestring'default'
...other--

ConnectLineOption Object

attributedescriptiontypedefault value
lineHeightThe height of the connecting line between the node and its child nodesstring'20px'
showArrowDoes the connection line between the node and its child nodes display arrowsbooleanfalse
lineColorThe color of the connector between the node and its parent nodestring'black'
lineWidthThe thickness of the connecting line between the node and its parent nodestring'2'
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago