Commit 83e529681afa77c652f0c454ae70488c3b9ed5f3

Authored by lzdjack
Committed by GitHub
1 parent 4d6f24d0

perf: 优化ApiRadioGroup回调函数change参数 (#2512)

src/components/Form/src/components/ApiRadioGroup.vue
@@ -2,12 +2,17 @@ @@ -2,12 +2,17 @@
2 * @Description:It is troublesome to implement radio button group in the form. So it is extracted independently as a separate component 2 * @Description:It is troublesome to implement radio button group in the form. So it is extracted independently as a separate component
3 --> 3 -->
4 <template> 4 <template>
5 - <RadioGroup v-bind="attrs" v-model:value="state" button-style="solid" @change="handleChange"> 5 + <RadioGroup v-bind="attrs" v-model:value="state" button-style="solid">
6 <template v-for="item in getOptions" :key="`${item.value}`"> 6 <template v-for="item in getOptions" :key="`${item.value}`">
7 - <RadioButton v-if="props.isBtn" :value="item.value" :disabled="item.disabled"> 7 + <RadioButton
  8 + v-if="props.isBtn"
  9 + :value="item.value"
  10 + :disabled="item.disabled"
  11 + @click="handleClick(item)"
  12 + >
8 {{ item.label }} 13 {{ item.label }}
9 </RadioButton> 14 </RadioButton>
10 - <Radio v-else :value="item.value" :disabled="item.disabled"> 15 + <Radio v-else :value="item.value" :disabled="item.disabled" @click="handleClick(item)">
11 {{ item.label }} 16 {{ item.label }}
12 </Radio> 17 </Radio>
13 </template> 18 </template>
@@ -62,7 +67,7 @@ @@ -62,7 +67,7 @@
62 const attrs = useAttrs(); 67 const attrs = useAttrs();
63 const { t } = useI18n(); 68 const { t } = useI18n();
64 // Embedded in the form, just use the hook binding to perform form verification 69 // Embedded in the form, just use the hook binding to perform form verification
65 - const [state] = useRuleFormItem(props); 70 + const [state] = useRuleFormItem(props, 'value', 'change', emitData);
66 71
67 // Processing options value 72 // Processing options value
68 const getOptions = computed(() => { 73 const getOptions = computed(() => {
@@ -120,11 +125,11 @@ @@ -120,11 +125,11 @@
120 emit('options-change', unref(getOptions)); 125 emit('options-change', unref(getOptions));
121 } 126 }
122 127
123 - function handleChange(_, ...args) { 128 + function handleClick(...args) {
124 emitData.value = args; 129 emitData.value = args;
125 } 130 }
126 131
127 - return { state, getOptions, attrs, loading, t, handleChange, props }; 132 + return { state, getOptions, attrs, loading, t, handleClick, props };
128 }, 133 },
129 }); 134 });
130 </script> 135 </script>