Transfer
Introduction
The Transfer component is used for moving data options between two columns. mengyue-components has encapsulated this component and conducted vitest testing. You can use <MYTransfer></MYTransfer> to implement data transfer functionality.
Basic Usage
Basic Transfer
A basic transfer component that supports moving data between left and right columns.
Code Demo
List One
- Option 3
- Option 4
- Disabled Option
List Two
- Option 1
- Option 2
展开代码
Custom Titles
Use the titles prop to customize the titles of the left and right columns.
Code Demo
Source List
- Apple
- Orange
- Mango
Target List
- Banana
- Grape
展开代码
Custom Colors
Use the backgroundColor, colorText, and hoverBackground props to customize the transfer component's colors.
Code Demo
Light Theme
- Option 2
- Option 4
Light Theme
- Option 1
- Option 3
展开代码
Dark Theme
Create a dark-themed transfer component using dark backgrounds.
Code Demo
Dark Theme
- Item 1
- Item 3
- Item 4
Dark Theme
- Item 2
- Item 5
展开代码
Disabled Options
Data containing disabled options that users cannot select or move.
Code Demo
Available List
- Available Item 1
- Disabled Item 1
- Available Item 3
- Disabled Item 2
- Available Item 4
Selected List
- Available Item 2
展开代码
Dynamic Data
Create a transfer component with dynamic data sources.
Code Demo
All Users
- Li Si
- Zhao Liu
- Qian Qi
Selected Users
- Zhang San
- Wang Wu
Selected users: Zhang San, Wang Wu
展开代码
API Reference
Transfer Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| modelValue | Array of selected item keys | number[] | — | [] |
| data | Data source | Option[] | — | [] |
| titles | Custom titles for left and right lists | string[] | — | [] |
| backgroundColor | Background color | string | — | '' |
| colorText | Text color | string | — | '' |
| hoverBackground | Hover background color | string | — | '' |
Data Types
typescript
interface Option {
key: number;
label: string;
disabled: boolean;
}
interface TransferProps {
modelValue: number[];
data: Option[];
titles?: string[];
backgroundColor?: string;
colorText?: string;
hoverBackground?: string;
}