Select
Brief Introduction
The select component is used for users to choose one or more options from a dropdown list.
There are two ways to implement the selector tags: <MYSelect /> or <MYSelect></MYSelect><MYOption /> or <MYOption></MYOption>
Basic Usage
Use v-model to bind the selected value.
Code Demo
Please select a fruit
展开代码
Disabled State
Disable Entire Selector
Use the disabled property to disable the selector.
Code Demo
Disabled state
展开代码
Disable a Specific Option
Use the disabled property to disable a single option.
Code Demo
Disable an option
展开代码
Custom Size
Use the width and height properties to customize the selector's width and height.
Code Demo
Width 300px Height 50px
展开代码
Custom Colors
Use the backgroundColor, hoverbackgroundColor, and borderColor properties to customize the selector's colors.
Code Demo
Custom colors
展开代码
API Reference
Select Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| modelValue | Bound value | string | number | — | '' |
| placeholder | Placeholder text | string | — | 'Please select' |
| disabled | Whether disabled | boolean | — | false |
| width | Width | string | number | — | '260px' |
| height | Height | string | number | — | '40px' |
| backgroundColor | Background color | string | — | '' |
| hoverbackgroundColor | Hover background color | string | — | '' |
| borderColor | Border color | string | — | '' |
| autoScrollbar | Auto scrollbar | boolean | — | true |
Option Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| value | Option value | string | number | — | — |
| label | Option label | string | — | '' |
| disabled | Whether disabled | boolean | — | false |
Type Definitions
typescript
interface SelectProps {
modelValue?: string | number;
placeholder?: string;
disabled?: boolean;
width?: string | number;
height?: string | number;
backgroundColor?: string;
hoverbackgroundColor?: string;
borderColor?: string;
autoScrollbar?: boolean;
}
interface OptionProps {
value: string | number;
label?: string;
disabled?: boolean;
}