From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/components/Form/src/components/useRenderRadio.tsx | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/components/Form/src/components/useRenderRadio.tsx b/src/components/Form/src/components/useRenderRadio.tsx
new file mode 100644
index 0000000..d1005ca
--- /dev/null
+++ b/src/components/Form/src/components/useRenderRadio.tsx
@@ -0,0 +1,26 @@
+import { FormSchema } from '@/types/form'
+import { ElRadio, ElRadioButton } from 'element-plus'
+import { defineComponent } from 'vue'
+
+export const useRenderRadio = () => {
+ const renderRadioOptions = (item: FormSchema) => {
+ // 濡傛灉鏈夊埆鍚嶏紝灏卞彇鍒悕
+ const labelAlias = item?.componentProps?.optionsAlias?.labelField
+ const valueAlias = item?.componentProps?.optionsAlias?.valueField
+ const Com = (item.component === 'Radio' ? ElRadio : ElRadioButton) as ReturnType<
+ typeof defineComponent
+ >
+ return item?.componentProps?.options?.map((option) => {
+ const { ...other } = option
+ return (
+ <Com {...other} label={option[valueAlias || 'value']}>
+ {option[labelAlias || 'label']}
+ </Com>
+ )
+ })
+ }
+
+ return {
+ renderRadioOptions
+ }
+}
--
Gitblit v1.8.0