diff --git a/src/components/common-form-control/index.vue b/src/components/common-form-control/index.vue index 83f0720..49f8200 100644 --- a/src/components/common-form-control/index.vue +++ b/src/components/common-form-control/index.vue @@ -78,6 +78,23 @@ const modelValue = computed({ } }) +const childTypeMapping = { // 自动映射子元素类型,配置的时候可以不写type + 'checkbox-group': 'checkbox', + 'radio-group': 'radio', + select: 'option' +} + +const children = computed(() => { + const option = props.option + const result = option.children || [] // 初始化一些默认值 + result.forEach(childItem => { + if (!childItem.type) { + childItem.type = childTypeMapping[option.type] + } + }) + return result +}) +