Skip to content

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

属性类型默认值说明
modelValuestring | string[]''绑定值
placeholderstring-输入框占位文本
separatorstring','字符串模式下的分隔符
minCountnumber1最少输入框数量

Events

事件参数说明
update:modelValuestring | 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,
  },
]);

Released under the MIT License.