wangzhibo
2026-07-16 b57020623cf0c946706573bf102e548c3a544423
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { isString } from "lodash-es";
import { getValue, isObject } from ".";
 
// 解析扩展组件
export function parseExtensionComponent(vnode: Render.Component) {
    if (["el-select", "el-radio-group", "el-checkbox-group"].includes(vnode.name!)) {
        const list = getValue(vnode.options || []);
 
        const children = (
            <div>
                {list.map((e, i) => {
                    let label: any;
                    let value: any;
 
                    if (isString(e)) {
                        label = value = e;
                    } else if (isObject(e)) {
                        label = e.label;
                        value = e.value;
                    } else {
                        return <cl-error-message title={`Component options error`} />;
                    }
 
                    switch (vnode.name) {
                        case "el-select":
                            return <el-option key={i} label={label} value={value} {...e.props} />;
                        case "el-radio-group":
                            return (
                                <el-radio key={i} value={value} {...e.props}>
                                    {label}
                                </el-radio>
                            );
                        case "el-checkbox-group":
                            return (
                                <el-checkbox key={i} value={value} {...e.props}>
                                    {label}
                                </el-checkbox>
                            );
                        default:
                            return null;
                    }
                })}
            </div>
        );
 
        return {
            children
        };
    } else {
        return {};
    }
}