Merge pull request #237 from lm356536/master

feat: 单选按钮组,支持图标icon的扩展,label改为可选
This commit is contained in:
JEECG
2022-11-14 22:29:00 +08:00
committed by GitHub

View File

@@ -5,7 +5,8 @@
<RadioGroup v-bind="attrs" v-model:value="state" button-style="solid">
<template v-for="item in getOptions" :key="`${item.value}`">
<RadioButton :value="item.value" :disabled="item.disabled">
{{ item.label }}
<Icon v-if="item.icon" :icon="item.icon" />
{{ item.label ? item.label : '' }}
</RadioButton>
</template>
</RadioGroup>
@@ -16,8 +17,13 @@
import { isString } from '/@/utils/is';
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { useAttrs } from '/@/hooks/core/useAttrs';
type OptionsItem = { label: string; value: string | number | boolean; disabled?: boolean };
import { Icon } from '/@/components/Icon';
type OptionsItem = {
icon?: string;
label?: string;
value: string | number | boolean;
disabled?: boolean;
};
type RadioItem = string | OptionsItem;
export default defineComponent({
@@ -25,6 +31,7 @@
components: {
RadioGroup: Radio.Group,
RadioButton: Radio.Button,
Icon,
},
props: {
value: {