单选框 Radio
单选框的基本用法。
按钮类型的单选框组
Section titled “按钮类型的单选框组”通过指定 type="button" ,可以显示按钮类型的单选框组。
通过 v-model (model-value) 属性控制是否选中
自定义单选框
Section titled “自定义单选框”使用 #radio 插槽自定义复选框的展示
单选框组方向
Section titled “单选框组方向”通过设置 direction="vertical" 可以展示竖直的单选框组。
通过 <sd-radio-group> 组件展示单选框组。
使用 <sd-radio-group> 传入 <sd-radio>,配合 <sd-grid> 组件实现灵活的布局。
单选框组选项
Section titled “单选框组选项”sd-radio-group 通过 options 属性设置子元素
按钮类型单选框组的尺寸
Section titled “按钮类型单选框组的尺寸”按钮类型的单选框组分为 mini、small、medium、large 四种尺寸。
<radio> Props
Section titled “<radio> Props”| 参数名 | 描述 | 类型 | 默认值 |
|---|---|---|---|
| model-value (v-model) | 绑定值 | string | number | boolean | - |
| default-checked | 默认是否选中(非受控状态) | boolean | false |
| value | 选项的 value | string | number | boolean | true |
| type | 单选的类型 | 'radio' | 'button' | 'radio' |
| disabled | 是否禁用 | boolean | false |
<radio> Events
Section titled “<radio> Events”| 事件名 | 描述 | 参数 |
|---|---|---|
| change | 值改变时触发 | value: string | number | booleanev: Event |
<radio> Slots
Section titled “<radio> Slots”| 插槽名 | 描述 | 参数 | 版本 |
|---|---|---|---|
| radio | 自定义单选框 | checked: booleandisabled: boolean | 2.18.0 |
<radio-group> Props
Section titled “<radio-group> Props”| 参数名 | 描述 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| model-value (v-model) | 绑定值 | string | number | boolean | - | |
| default-value | 默认值(非受控状态) | string | number | boolean | '' | |
| type | 单选框组的类型 | 'radio' | 'button' | 'radio' | |
| size | 单选框组的尺寸 | 'mini' | 'small' | 'medium' | 'large' | - | |
| options | 选项 | Array<string | number | RadioOption> | - | 2.27.0 |
| direction | 单选框组的方向 | 'horizontal' | 'vertical' | 'horizontal' | |
| disabled | 是否禁用 | boolean | false |
<radio-group> Events
Section titled “<radio-group> Events”| 事件名 | 描述 | 参数 |
|---|---|---|
| change | 值改变时触发 | value: string | number | boolean |
<radio-group> Slots
Section titled “<radio-group> Slots”| 插槽名 | 描述 | 参数 | 版本 |
|---|---|---|---|
| radio | 自定义单选框 | checked: booleandisabled: boolean | 2.27.0 |
| label | radio 文案内容 | data: RadioOption | 2.27.0 |
RadioOption
Section titled “RadioOption”| 参数名 | 描述 | 类型 | 默认值 |
|---|---|---|---|
| label | 文案 | RenderContent | - |
| value | 选项的 value | string | number | - |
| disabled | 是否禁用 | boolean | false |