Skip to content
目录

Select

Select a value from options.

Basic

html
<template>
  <dk-select v-model="value" :options="options" />
</template>

<script setup>
import { ref } from 'vue'

const value = ref('')
const options = [
  { label: 'Option A', value: 'A' },
  { label: 'Option B', value: 'B' },
  { label: 'Disabled', value: 'X', disabled: true }
]
</script>
展开

Options

html
<template>
  <dk-select v-model="value" :options="options" :props="props" />
</template>

<script setup>
import { ref } from 'vue'

const value = ref('')
const options = [
  { name: 'Option A', id: 'A' },
  { name: 'Option B', id: 'B' },
  { name: 'Disabled', id: 'X', isDisabled: true }
]
const props = { label: 'name', value: 'id', disabled: 'isDisabled' }
</script>
展开

Disabled Option

html
<template>
  <dk-select v-model="value" :options="options" />
</template>
展开

Disabled

html
<template>
  <dk-select v-model="value" disabled :options="options" />
</template>
展开

Clearable

html
<template>
  <dk-select v-model="value" clearable :options="options" />
</template>
展开

Size

html
<template>
  <dk-select v-model="value" size="large" :options="options" />
  <dk-select v-model="value" size="medium" :options="options" />
  <dk-select v-model="value" size="small" :options="options" />
  <dk-select v-model="value" size="mini" :options="options" />
</template>
展开

Multiple

Option A
html
<template>
  <dk-select v-model="value" multiple :options="options" />
</template>
展开

Collapse Tags

Option A
html
<template>
  <dk-select v-model="value" multiple collapse-tags :options="options" />
</template>
展开

Max Collapse Tags

Option A
html
<template>
  <dk-select v-model="value" multiple collapse-tags :max-collapse-tags="1" :options="options" />
</template>
展开

Custom Option Template

html
<template>
  <dk-select v-model="value">
    <dk-option label="Beijing" value="beijing">...</dk-option>
  </dk-select>
</template>
展开
html
<template>
  <dk-select v-model="value" :options="options">
    <template #header>...</template>
    <template #footer>...</template>
  </dk-select>
</template>
展开

Option Group

html
<template>
  <dk-select v-model="value">
    <dk-option-group label="Popular cities">
      <dk-option label="Shanghai" value="shanghai" />
      <dk-option label="Beijing" value="beijing" />
    </dk-option-group>
  </dk-select>
</template>
展开

Value Key

When binding value is an object, set value-key as the unique key.

html
<template>
  <dk-select v-model="value" :options="options" value-key="id" />
</template>
展开

Custom Loading & Empty

html
<template>
  <dk-select v-model="value" loading>
    <template #loading>...</template>
  </dk-select>
  <dk-select v-model="value" :options="[]">
    <template #empty>...</template>
  </dk-select>
</template>
展开
html
<template>
  <dk-select v-model="value" filterable remote :remote-method="remoteMethod" :loading="loading" :options="options" />
</template>
展开

Props

NameDescriptionTypeDefault
model-value / v-modelbinding valuestring | number | boolean | object | array''
optionsoptions list (array mode)array[]
propsfield mapping (value/label/disabled/options)object-
disableddisabledbooleanfalse
multiplemultiplebooleanfalse
clearableclearablebooleantrue
filterablefilterablebooleanfalse
filter-methodcustom filter method(query: string) => boolean-
remoteremote searchbooleanfalse
remote-methodremote method(query: string) => void-
debouncedebounce(ms)number300
loadingloadingbooleanfalse
loading-textloading textstring'Loading'
no-match-textno match textstring'无匹配数据'
no-data-textno data textstring'无数据'
placeholderplaceholderstring'请选择'
widthwidthstring'240px'
sizesizelarge / medium / small / mini-
value-keyunique key when value is objectstring'value'
collapse-tagscollapse tags (multiple)booleanfalse
max-collapse-tagsmax tags shownnumber1
popper-classdropdown classstring''
popper-styledropdown stylestring | object''
teleportedteleportedbooleantrue
append-toteleport targetstring | HTMLElement'body'
offsetdropdown offsetnumber8
suffix-iconsuffix iconstring'IconCaretDown'
clear-iconclear iconstring'IconClose'

Slots

NameDescription
defaultcustom options (with DkOption / DkOptionGroup)
headerdropdown header
footerdropdown footer
loadingloading content
emptyempty content

Events

NameDescriptionParams
update:modelValuev-model update(value)
changevalue changed(value)
clearcleared-
visible-changedropdown visibility(visible: boolean)
focusfocus(evt: FocusEvent)
blurblur(evt: FocusEvent)
remove-tagremove a tag (multiple)(tagValue)
popup-scrolldropdown scroll(evt: Event)

Contributors

Mr.Fan