Select 选择器
下拉选择
基本用法
选择器基本用法
<template>
<tu-space vertical>
<tu-select v-model:value="value" :options="options"/>
<tu-select v-model:value="value" :options="options" disabled/>
</tu-space>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectOption } from '../../../src/components/select/src/Select'
const value = ref(null)
const options = ref<SelectOption[]>([])
function createOptions() {
let index = -1
while (++index < 12) {
const item = {
value: `${index + 1}`,
label: `Option ${index + 1}`
}
options.value.push(item)
}
options.value[2].disabled = true
}
createOptions()
</script>
<style>
.demo-select .tu-select {
width: 240px;
}
</style>
展开源码
多选
可以选择多个
<template>
<tu-space vertical>
<tu-select v-model:value="value" :options="options" multiple clearable/>
<tu-select v-model:value="value" :options="options" multiple clearable disabled/>
</tu-space>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectOption } from '../../../src/components/select/src/Select'
const value = ref(null)
const options = ref<SelectOption[]>([])
function createOptions() {
let index = -1
while (++index < 12) {
const item = {
value: `${index + 1}`,
label: `Option ${index + 1}`
}
options.value.push(item)
}
options.value[2].disabled = true
}
createOptions()
</script>
展开源码
可清空
<template>
<tu-select v-model:value="value" :options="options" clearable/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectOption } from '../../../src/components/select/src/Select'
const value = ref(null)
const options = ref<SelectOption[]>([])
function createOptions() {
let index = -1
while (++index < 12) {
const item = {
value: `${index + 1}`,
label: `Option ${index + 1}`
}
options.value.push(item)
}
options.value[2].disabled = true
}
createOptions()
</script>
<style>
.demo-select .tu-select {
width: 240px;
}
</style>
展开源码
尺寸
<template>
<tu-space vertical>
<tu-select v-model:value="value" :options="options" size="small"/>
<tu-select v-model:value="value" :options="options"/>
<tu-select v-model:value="value" :options="options" size="large"/>
</tu-space>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectOption } from '../../../src/components/select/src/Select'
const value = ref(null)
const options = ref<SelectOption[]>([])
function createOptions() {
let index = -1
while (++index < 12) {
const item = {
value: `${index + 1}`,
label: `Option ${index + 1}`
}
options.value.push(item)
}
options.value[2].disabled = true
}
createOptions()
</script>
<style>
.demo-select .tu-select {
width: 240px;
}
</style>
展开源码
Select 属性
名称 | 说明 | 类型 | 默认值 |
---|---|---|---|
value | 选中的值 | string | number | undefined |
options | 下拉选项列表 | Array<strin | number> | [] |
value-field | SelectOption 的 value 字段名 | string | 'value' |
label-field | SelectOption 的 label 字段名 | string | 'label' |
disabled-field | SelectOption 的 disabled 字段名 | string | 'disabled' |
clearable | 是否可清空 | boolean | false |
disabled | 是否禁用 | boolean | false |
multiple | 是否可多选 | boolean | false |