UNPKG

@ozo/react-rock

Version:

React 移动端开发脚手架,基于CRA3,通用、开箱即用。

25 lines (22 loc) 595 B
import { cloneDeep } from 'lodash-es'; /** * 组装数据 * @param {array} src 原始数据 * @param {array} ext 扩展数据,默认值[] * @returns {array} 组装后的值 */ export function assembleFormConfig(src = [], ext = []) { if (ext.length === 0) { return src; } const tData = cloneDeep(src); ext.forEach((item) => { const tId = item.key; const tIndex = tData.findIndex((it) => { return it.key === tId; }); const { key, ...rest } = item; Object.assign(tData[tIndex], rest); }); return tData; }