feat: 单选按钮组,添加图片的扩展
parent
565957033e
commit
836070b165
|
@ -5,7 +5,8 @@
|
||||||
<RadioGroup v-bind="attrs" v-model:value="state" button-style="solid">
|
<RadioGroup v-bind="attrs" v-model:value="state" button-style="solid">
|
||||||
<template v-for="item in getOptions" :key="`${item.value}`">
|
<template v-for="item in getOptions" :key="`${item.value}`">
|
||||||
<RadioButton :value="item.value" :disabled="item.disabled">
|
<RadioButton :value="item.value" :disabled="item.disabled">
|
||||||
{{ item.label }}
|
<Icon v-if="item.icon" :icon="item.icon" />
|
||||||
|
{{ item.label ? item.label : '' }}
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
</template>
|
</template>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
@ -16,8 +17,13 @@
|
||||||
import { isString } from '/@/utils/is';
|
import { isString } from '/@/utils/is';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
|
import { Icon } from '/@/components/Icon';
|
||||||
type OptionsItem = { label: string; value: string | number | boolean; disabled?: boolean };
|
type OptionsItem = {
|
||||||
|
icon?: string;
|
||||||
|
label?: string;
|
||||||
|
value: string | number | boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
};
|
||||||
type RadioItem = string | OptionsItem;
|
type RadioItem = string | OptionsItem;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
@ -25,6 +31,7 @@
|
||||||
components: {
|
components: {
|
||||||
RadioGroup: Radio.Group,
|
RadioGroup: Radio.Group,
|
||||||
RadioButton: Radio.Button,
|
RadioButton: Radio.Button,
|
||||||
|
Icon,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
|
|
Loading…
Reference in New Issue