@form-create/vant
Version:
Vant 版本(移动端)低代码表单 | FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。
16 lines (15 loc) • 520 B
JavaScript
export const normalizeOptions = (options) => {
if (!options || !Array.isArray(options)) {
return [];
}
return options.map(item => {
const normalized = {...item};
if (normalized.label !== undefined && normalized.text === undefined) {
normalized.text = normalized.label;
}
if (normalized.children && Array.isArray(normalized.children)) {
normalized.children = normalizeOptions(normalized.children);
}
return normalized;
})
};