CondorArray
CondorArray 是一个可拖拽、可编辑的动态数组组件,用于管理键值对(或更多字段)的列表数据。支持添加、删除、重新排序操作,并提供了国际化支持。
组件 Props
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value | any[] | [] | 绑定的数组数据 |
| header | boolean | true | 是否显示表头 |
| keys | string[] | ['label', 'value'] | 定义数组项包含的字段名 |
| labels | string[] | ['condor.common.key', 'condor.common.value'] | 表头显示的文字(国际化键名) |
组件事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| update:value | 当数组数据变化时触发 | 更新后的数组 |
基本用法
1. 基本键值对数组
vue
<template>
<CondorArray v-model:value="arrayData" />
</template>
<script setup lang="ts">
import { ref } from 'vue';
const arrayData = ref([
{ label: '姓名', value: '张三' },
{ label: '年龄', value: '25' },
{ label: '城市', value: '北京' }
]);
</script>2. 自定义字段(三个字段)
vue
<template>
<CondorArray
v-model:value="userList"
:keys="['id', 'name', 'email']"
:labels="['用户ID', '用户名', '邮箱']"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const userList = ref([
{ id: '1', name: '张三', email: 'zhangsan@example.com' },
{ id: '2', name: '李四', email: 'lisi@example.com' }
]);
</script>