Transfer 穿梭框

基础用法

可搜索过滤

在数据很多的情况下,可以对数据进行搜索和过滤。

自定义

可以对列表标题文案、按钮文案、数据项的渲染函数、列表底部的勾选状态文案、列表底部的内容区等进行自定义。

数据项属性别名

默认情况下,Transfer 仅能识别数据项中的 keylabeldisabled 字段。 如果你的数据的字段名不同,可以使用 props 属性为它们设置别名。

API

Attributes

属性名说明类型Default
model-value / v-model选中项绑定值object[]
dataTransfer 的数据源object[]
filterable是否可搜索booleanfalse
filter-placeholder搜索框占位符string
filter-method自定义搜索方法Function
target-order右侧列表元素的排序策略: 若为 original,则保持与数据源相同的顺序; 若为 push,则新加入的元素排在最后; 若为 unshift,则新加入的元素排在最前enumoriginal
titles自定义列表标题object[]
button-texts自定义按钮文案object[]
render-content自定义数据项渲染函数object
format列表顶部勾选状态文案object{}
props数据源的字段别名object
left-default-checked初始状态下左侧列表的已勾选项的 key 数组object[]
right-default-checked初始状态下右侧列表的已勾选项的 key 数组object[]
validate-event是否触发表单验证booleantrue

Events

插槽名说明Type
change右侧列表元素变化时触发Function
left-check-change左侧列表元素被用户选中 / 取消选中时触发Function
right-check-change右侧列表元素被用户选中 / 取消选中时触发Function

Slots

Name说明
default自定义数据项的内容, The scope parameter is
left-footer左侧列表底部的内容
right-footer右侧列表底部的内容

Exposes

Method说明Type
clearQuery清空某个面板的搜索关键词Function

Type Declarations

Show declarations
import type { h as H, VNode } from 'vue'

type TransferKey = string | number

type TransferDirection = 'left' | 'right'

type TransferDataItem = Record<string, any>

type renderContent = (h: typeof H, option: TransferDataItem) => VNode | VNode[]

interface TransferFormat {
  noChecked?: string
  hasChecked?: string
}

interface TransferPropsAlias {
  label?: string
  key?: string
  disabled?: string
}

源代码

组件文档

贡献者