Skip to content
API 风格:

InputTag 標籤輸入 ​

LhInputTag 標籤輸入框:Enter 生成標籤,Backspace 刪除尾項。

基礎用法 ​

基礎用法
VueVite
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhInputTag } from '@lh-ui/vue3'

const tags = ref(['Vue', 'Vite'])
const t1 = {
  placeholder: '輸入標籤後 Enter',
}
</script>

<template>
<LhInputTag v-model="tags" :placeholder="t1.placeholder" />
</template>
vue
<script>
import { LhInputTag } from '@lh-ui/vue3'

export default {
  components: { LhInputTag },
  data() {
    return {
      tags: ['Vue', 'Vite'],
      t1: {
      placeholder: '輸入標籤後 Enter',
    },
    }
  },
}
</script>

<template>
<LhInputTag v-model="tags" :placeholder="t1.placeholder" />
</template>
觸發鍵與上限
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhInputTag } from '@lh-ui/vue3'

const tags2 = ref([])
const t2 = {
  placeholder2: '空格觸發,最多 5 個',
}
</script>

<template>
<LhInputTag v-model="tags2" trigger="space" :max="5" :placeholder="t2.placeholder2" />
</template>
vue
<script>
import { LhInputTag } from '@lh-ui/vue3'

export default {
  components: { LhInputTag },
  data() {
    return {
      tags2: [],
      t2: {
      placeholder2: '空格觸發,最多 5 個',
    },
    }
  },
}
</script>

<template>
<LhInputTag v-model="tags2" trigger="space" :max="5" :placeholder="t2.placeholder2" />
</template>

InputTag API ​

屬性 ​

屬性名說明類型預設值
modelValue標籤列表string[][]
trigger提交觸發鍵LhInputTagTrigger'enter'
placeholder佔位提示string''
max標籤上限number0
allowDuplicate允許重複標籤booleanfalse
readonly唯讀booleanfalse
disabled停用booleanfalse
ariaLabel無障礙名稱string—
sx快速版面配置屬性LhSxProps—

事件 ​

屬性名說明類型
update:modelValue標籤列表變化時觸發(value: string[])
change標籤列表變化時觸發(value: string[])
add提交單個標籤時觸發(tag: string)
remove移除單個標籤時觸發(tag: string)

無障礙 ​

  • 輸入框帶 aria-label
  • 輸入為空時 Backspace 刪除尾項