Skip to content

树形穿梭框组件

基础用法

源列表4/0
Node 1
Node 1-1
Node 1-2
Node 2
目标列表0/0

<script setup>
import { ref } from "vue";
import { TransferTree } from "@otdrfu/element-plus-pro";

const data = ref([
  {
    id: "1",
    label: "Node 1",
    children: [
      {
        id: "1-1",
        label: "Node 1-1",
      },
      {
        id: "1-2",
        label: "Node 1-2",
      },
    ],
  },
  {
    id: "2",
    label: "Node 2",
    children: [],
  },
]);
</script>

<template>
  <TransferTree filterable :defaultCheckedKeys="['1']" :data-source="data" />
</template>

Attributes

参数说明类型可选值默认值
width容器总宽度string800px
height容器总高度string500px
dataSource左侧树数据源array[ ]
nodeKeyel-tree的key(必须唯一)stringid
defaultPropsel-tree 配置项Object{ label: "label", children: "children" }
default-checked-keys左侧树默认选中穿梭节点array[ ]
default-expanded-keys树默认展开节点array[ ]
accordion是否每次只打开一个树节点booleanfalse
render-after-expand是否在第一次展开某个树节点后才渲染其子节点booleantrue
expand-on-click-node是否在点击节点的时候展开或者收缩节点booleantrue
father-choose是否严格的遵循父子不互相关联的做法, 父节点是否可被选择穿梭booleanfalse
isRadio左侧数据源是否为单选booleanfalse
openAll树节点是否默认展开booleantrue
filterable是否可搜索booleanfalse
filter-placeholder搜索框占位符string请输入搜索内容
filter-method自定义搜索方法function
titles自定义标题array['源数据', '目标列表']
button-texts自定义按钮文案array[ ]
listSortFifo右侧列表排序方式:默认值:true,右侧列表中结点根据左侧树选中结点先后顺序排序;可选值:false,右侧列表中结点根据左侧树结构排序booleantrue

Slot

name说明
left-footer左侧列表底部的内容
right-footer右侧列表底部的内容

Methods

方法名说明参数
clearQuery清空某个面板的搜索关键词'left' / 'right' / 'all',指定需要清空的搜索框
getTreeChecked获取左侧树全部选中状态'leftKeys', 'leftHarfKeys', 'leftNodes', 'leftHalfNodes'

Events

事件名称说明回调参数
change选项在两栏之间转移时触发当前值、数据移动的方向('left' / 'right')、发生移动的数据 key 数组
left-check-change左侧列表元素被用户选中 / 取消选中时触发当前被选中的元素的 key 数组、选中状态发生变化的元素的 key 数组
right-check-change右侧列表元素被用户选中 / 取消选中时触发当前被选中的元素的 key 数组、选中状态发生变化的元素的 key 数组

TIP

基于 element-tree-transfer-pro 组件,vue2版本使用文档请参考: element-tree-transfer-pro