[Vuejs]-Antdv vuejs select max number of items

0👍

You can create a computed to disable unselected items when 4 items are selected

const optionsComputed = computed( () => {
  return items.value.length < 4 ? itemOptions.value : itemOptions.value.map(item => {
    return items.value.includes(item.value) ? item : {...item, disabled: true}
  })
})

Template

<a-select
  v-model:value="items"
  mode="tags"
  placeholder="Select at least one item"
  :options="optionsComputed"
/>

Leave a comment