AddableInputGroup
可动态添加/删除的输入框组组件,返回逗号分隔字符串或数组。
基础用法
vue
<script setup>
import { ref } from "vue";
import { AddableInputGroup } from "vue-admin-kit";
const tags = ref("");
</script>
<template>
<AddableInputGroup v-model="tags" placeholder="请输入标签" />
</template>Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
modelValue | string | string[] | '' | 绑定值 |
placeholder | string | - | 输入框占位文本 |
separator | string | ',' | 字符串模式下的分隔符 |
minCount | number | 1 | 最少输入框数量 |
Events
| 事件 | 参数 | 说明 |
|---|---|---|
update:modelValue | string | string[] | 值变化时触发 |
enter | - | 按下回车键时触发 |
返回值格式
根据初始值类型自动判断返回格式:
typescript
// 字符串模式(默认)
const tags = ref("");
// 输入后:'标签1,标签2,标签3'
// 数组模式
const tags = ref([]);
// 输入后:['标签1', '标签2', '标签3']在表单配置中使用
typescript
const formConfig = defineFormConfig([
{
type: "addableInputGroup",
prop: "keywords",
label: "关键词",
placeholder: "请输入关键词",
minCount: 1,
},
]);