feat: radio support number option

pull/5361/head
tangjinzhou 3 years ago
parent 71e110036e
commit 5c9aea8a19

@ -27,7 +27,7 @@ const radioGroupProps = {
value: PropTypes.any,
size: PropTypes.oneOf(RadioGroupSizeTypes).def('default'),
options: {
type: Array as PropType<Array<String | RadioGroupChildOption>>,
type: Array as PropType<Array<string | RadioGroupChildOption | number>>,
},
disabled: PropTypes.looseBool,
name: PropTypes.string,
@ -95,7 +95,7 @@ export default defineComponent({
const optionsPrefixCls =
optionType === 'button' ? `${prefixCls.value}-button` : prefixCls.value;
children = options.map(option => {
if (typeof option === 'string') {
if (typeof option === 'string' || typeof option === 'number') {
return (
<Radio
key={option}

@ -32,7 +32,7 @@ Radio group can wrap a group of `Radio`。
| buttonStyle | style type of radio button | `outline` \| `solid` | `outline` | |
| disabled | Disable all radio buttons | boolean | false | |
| name | The `name` property of all `input[type="radio"]` children | string | - | |
| options | set children optional | string\[] \| Array&lt;{ label: string value: string disabled?: boolean }> | - | |
| options | set children optional | string\[] \| number\[] \| Array&lt;{ label: string value: string disabled?: boolean }> | - | |
| optionType | Set Radio optionType | `default` \| `button` | `default` | 3.0.0 |
| size | size for radio button style | `large` \| `default` \| `small` | `default` | |
| value(v-model) | Used for setting the currently selected value. | any | - | |

@ -33,7 +33,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/8cYb5seNB/Radio.svg
| buttonStyle | RadioButton 的风格样式,目前有描边和填色两种风格 | `outline` \| `solid` | `outline` | |
| disabled | 禁选所有子单选器 | boolean | false | |
| name | RadioGroup 下所有 `input[type="radio"]``name` 属性 | string | - | |
| options | 以配置形式设置子元素 | string\[] \| Array&lt;{ label: string value: string disabled?: boolean }> | - | |
| options | 以配置形式设置子元素 | string\[] \| number[] \| Array&lt;{ label: string value: string disabled?: boolean }> | - | |
| optionType | 用于设置 Radio `options` 类型 | `default` \| `button` | `default` | 3.0.0 |
| size | 大小,只对按钮样式生效 | `large` \| `default` \| `small` | `default` | |
| value(v-model) | 用于设置当前选中的值 | any | - | |

@ -174,7 +174,7 @@ span.@{radio-prefix-cls} + * {
display: inline-block;
height: @btn-height-base;
margin: 0;
padding: 0 @padding-md - 1px;
padding: 0 @radio-button-padding-horizontal;
color: @radio-button-color;
font-size: @font-size-base;
line-height: @btn-height-base - 2px;

Loading…
Cancel
Save