fix: 修复RadioButtonGroup组件返回值不正确的bug (#2513)
This commit is contained in:
parent
83e529681a
commit
d3ec7a58ad
|
|
@ -4,14 +4,14 @@
|
||||||
<template>
|
<template>
|
||||||
<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" @click="handleClick(item)">
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
</template>
|
</template>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, PropType, computed } from 'vue';
|
import { defineComponent, PropType, computed, ref } from 'vue';
|
||||||
import { Radio } from 'ant-design-vue';
|
import { Radio } from 'ant-design-vue';
|
||||||
import { isString } from '/@/utils/is';
|
import { isString } from '/@/utils/is';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
|
|
@ -35,10 +35,12 @@
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
emits: ['change'],
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
const emitData = ref<any[]>([]);
|
||||||
// Embedded in the form, just use the hook binding to perform form verification
|
// Embedded in the form, just use the hook binding to perform form verification
|
||||||
const [state] = useRuleFormItem(props);
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
|
|
||||||
// Processing options value
|
// Processing options value
|
||||||
const getOptions = computed((): OptionsItem[] => {
|
const getOptions = computed((): OptionsItem[] => {
|
||||||
|
|
@ -51,7 +53,11 @@
|
||||||
return options.map((item) => ({ label: item, value: item })) as OptionsItem[];
|
return options.map((item) => ({ label: item, value: item })) as OptionsItem[];
|
||||||
});
|
});
|
||||||
|
|
||||||
return { state, getOptions, attrs };
|
function handleClick(...args) {
|
||||||
|
emitData.value = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { state, getOptions, attrs, handleClick };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue