1.0.5 • Published 8 months ago

el-tree-transfer-pro v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

el-tree-transfer-pro

npm.io npm.io 使用WebStorm开发维护

A Vue3 + Element Plus based tree shuttle component. Styles inherit from Element Plus

一个基于Vue3 + Element Plus 树形穿梭组件。样式继承Element Plus

Installation

npm i el-tree-transfer-pro

Features

  • 灵活的返回值,可返回对象,自定义Node字段值数组
  • 带有过滤输入框

Usage

<template>
  <el-tree-transfer-pro
      v-model="value"
      :data="data"
      :children-is-empty="true"
      :show-filter="true"
      :node-props="nodeProps"
  />
</template>

<script setup>
import ElTreeTransferPro from "el-tree-transfer-pro"
import {ref, watch} from 'vue'

const nodeProps = ref({
  label: 'label',
  children: 'children',
  value: 'id', // value field
  disabled: 'disabled'
})

const value = ref([])

watch(value, (newValue) => {
  console.log('el-tree-transfer-pro', newValue)
})

const data = ref([
  {
    id: 1,
    label: 'Level one 1',
    pid: 0,
    children: [
      {
        id: 4,
        pid: 1,
        label: 'Level two 1-1',
        children: [
          {
            id: 9,
            pid: 4,
            label: 'Level three 1-1-1'
          },
          {
            id: 10,
            pid: 4,
            label: 'Level three 1-1-2'
          }
        ]
      }
    ]
  },
  {
    id: 2,
    pid: 0,
    label: 'Level one 2',
    children: [
      {
        id: 5,
        pid: 2,
        label: 'Level two 2-1'
      },
      {
        id: 6,
        pid: 2,
        label: 'Level two 2-2'
      }
    ]
  },
  {
    id: 3,
    pid: 0,
    label: 'Level one 3',
    children: [
      {
        id: 7,
        pid: 3,
        label: 'Level two 3-1'
      },
      {
        id: 8,
        pid: 3,
        label: 'Level two 3-2'
      }
    ]
  }
])
</script>

Attrs

属性名说明类型默认值
data展示数据array
empty-text数据为空的时候展示的文本string
titles树形选择框上的标题array'待选','已选'
buttonTexts穿梭左右按钮文本array
children-is-empty统计只有children节点为空的数据项booleantrue
count-key用于统计的数据keystring
count-value用于统计的数据值Valueany
show-filter显示过滤输入框booleantrue
filter-placeholder过滤输入框提示语string
node-key每个树节点用来作为唯一标识的属性,整棵树应该是唯一的string
node-props配置选项,具体看下表object
default-expand-all是否默认展开所有节点booleantrue
expand-on-click-node是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。booleanfalse
check-on-click-node是否在点击节点的时候选中节点,默认值为 false,即只有在点击复选框时才会选中节点。booleanfalse

Node Props

Props说明类型可选值默认值
label指定节点标签为节点对象的某个属性值string, function(data, node)label
children指定子树为节点对象的某个属性值stringchildren
disabled指定节点选择框是否禁用为节点对象的某个属性值string, function(data, node)
value指定获取的值为数据对象中某个字段, 如果为空将返回node 对象stringvalue
class自定义节点类名string, function(data, node)
1.0.5

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago