Radio 单选框
在一组备选项中进行单选。
基础用法
由于选项默认可见,不宜过多,若选项过多,建议使用 Select 选择器。
受控和非受控模式
非受控模式
使用 v-model
双向绑定,组件内部管理状态。
当前值: option1
受控模式
使用 :model-value
单向绑定配合 @change
或 @update:modelValue
事件,由父组件完全控制状态。
当前值: controlled1
当前值: update1
禁用状态
单选框不可用的状态。
单选框组
适用于在多个互斥的选项中选择的场景。
尺寸
使用 size
属性改变单选框大小。
API
Radio Props
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
modelValue | string | number | boolean | — | 绑定值 |
size | 'small' | 'medium' | 'large' | 'medium' | 单选框大小 |
disabled | boolean | false | 是否禁用 |
value | string | number | boolean | — | 单选框对应的值 |
label | string | — | 单选框的文本 |
customClass | string | — | 自定义类名 |
customStyle | string | object | — | 自定义样式 |
RadioGroup Props
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
modelValue | string | number | boolean | — | 绑定值 |
size | 'small' | 'medium' | 'large' | 'medium' | 单选框组大小 |
disabled | boolean | false | 是否禁用 |
customClass | string | — | 自定义类名 |
customStyle | string | object | — | 自定义样式 |
Radio Events
名称 | 参数 | 说明 |
---|---|---|
change | (value: string | number | boolean) => void | 当绑定值变化时触发 |
RadioGroup Events
名称 | 参数 | 说明 |
---|---|---|
change | (value: string | number | boolean) => void | 当绑定值变化时触发 |
Radio Slots
名称 | 说明 |
---|---|
default | 单选框的文本 |
RadioGroup Slots
名称 | 说明 |
---|---|
default | 单选框组的内容 |
Radio Methods
名称 | 说明 |
---|---|
focus | 使单选框获取焦点 |
blur | 使单选框失去焦点 |