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 = (
{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 ;
}
switch (vnode.name) {
case "el-select":
return ;
case "el-radio-group":
return (
{label}
);
case "el-checkbox-group":
return (
{label}
);
default:
return null;
}
})}
);
return {
children
};
} else {
return {};
}
}