2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2016-07-21 10:10:04 +08:00
|
|
|
|
subtitle: 单选框
|
2018-11-04 16:20:35 +08:00
|
|
|
|
type: 数据录入
|
2016-07-21 10:10:04 +08:00
|
|
|
|
title: Radio
|
2020-06-05 13:50:09 +08:00
|
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/8cYb5seNB/Radio.svg
|
2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
2015-07-16 18:23:25 +08:00
|
|
|
|
|
2015-07-28 20:22:37 +08:00
|
|
|
|
单选框。
|
|
|
|
|
|
2015-07-16 18:23:25 +08:00
|
|
|
|
## 何时使用
|
|
|
|
|
|
2015-07-16 22:40:49 +08:00
|
|
|
|
- 用于在多个备选项中选中单个状态。
|
|
|
|
|
- 和 Select 的区别是,Radio 所有选项默认可见,方便用户在比较中选择,因此选项不宜过多。
|
|
|
|
|
|
2015-07-16 18:23:25 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2020-02-26 16:09:22 +08:00
|
|
|
|
### Radio/Radio.Button
|
2015-07-17 16:06:46 +08:00
|
|
|
|
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
|
| --- | --- | --- | --- |
|
|
|
|
|
| autoFocus | 自动获取焦点 | boolean | false |
|
|
|
|
|
| checked | 指定当前是否选中 | boolean | false |
|
|
|
|
|
| defaultChecked | 初始是否选中 | boolean | false |
|
|
|
|
|
| disabled | 禁用 Radio | boolean | false |
|
|
|
|
|
| value | 根据 value 进行比较,判断是否选中 | any | - |
|
2015-07-17 16:06:46 +08:00
|
|
|
|
|
|
|
|
|
### RadioGroup
|
|
|
|
|
|
2015-07-28 20:22:37 +08:00
|
|
|
|
单选框组合,用于包裹一组 `Radio`。
|
2015-07-20 22:36:49 +08:00
|
|
|
|
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 | |
|
|
|
|
|
| --- | --- | --- | --- | --- | --- |
|
|
|
|
|
| buttonStyle | RadioButton 的风格样式,目前有描边和填色两种风格 | `outline` \| `solid` | `outline` | | |
|
|
|
|
|
| defaultValue | 默认选中的值 | any | - | | |
|
2020-07-01 16:21:56 +08:00
|
|
|
|
| disabled | 禁选所有子单选器 | boolean | false | | |
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| name | RadioGroup 下所有 `input[type="radio"]` 的 `name` 属性 | string | - | | |
|
|
|
|
|
| options | 以配置形式设置子元素 | string\[] \| Array<{ label: string value: string disabled?: boolean }> | - | | |
|
|
|
|
|
| optionType | 用于设置 Radio `options` 类型 | `default` \| `button` | `default` | 4.4.0 | |
|
|
|
|
|
| size | 大小,只对按钮样式生效 | `large` \| `middle` \| `small` | - | | |
|
|
|
|
|
| value | 用于设置当前选中的值 | any | - | | |
|
|
|
|
|
| onChange | 选项变化时的回调函数 | function(e:Event) | - | | |
|
2017-12-01 19:28:41 +08:00
|
|
|
|
|
|
|
|
|
## 方法
|
|
|
|
|
|
|
|
|
|
### Radio
|
|
|
|
|
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| 名称 | 描述 |
|
|
|
|
|
| --- | --- |
|
|
|
|
|
| blur() | 移除焦点 |
|
2019-11-22 14:37:39 +08:00
|
|
|
|
| focus() | 获取焦点 |
|