From ba35594edf7f9a1c1b7fa2069c0118538f4c40a7 Mon Sep 17 00:00:00 2001 From: EVILLT <53422750+eviIIt@users.noreply.github.com> Date: Sun, 29 Sep 2019 15:40:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3`File`=20=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #106 --- src/el-form-renderer.js | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/el-form-renderer.js b/src/el-form-renderer.js index 31d546e..c821f13 100644 --- a/src/el-form-renderer.js +++ b/src/el-form-renderer.js @@ -5,25 +5,6 @@ import RenderFormItem from './render-form-item' import transformContent from './transform-content' import {isObject} from './utils' -// 拷贝简单数据 -// 不考虑引用,函数等复杂数据 -function clone(data) { - if (Array.isArray(data)) { - return data.map(clone) - } else if (data && typeof data === 'object') { - let obj = Object.assign({}, data) - for (let key in obj) { - if (!obj.hasOwnProperty(key)) continue - if (typeof obj[key] === 'object') { - obj[key] = clone(obj[key]) - } - } - return obj - } else { - return data - } -} - const GROUP = 'group' export default { @@ -188,20 +169,20 @@ export default { acc[key] = getValue(values[key], item.items) } else { if (item.outputFormat) { - const formatVal = item.outputFormat(clone(values[key])) + const formatVal = item.outputFormat(values[key]) // 如果 outputFormat 返回的是一个对象,则合并该对象,否则在原有 acc 上新增该 属性:值 isObject(formatVal) ? Object.assign(acc, formatVal) : (acc[key] = formatVal) } else { - acc[key] = clone(values[key]) + acc[key] = values[key] } } return acc }, {}) } - return getValue(this.value, this._content) + return {...getValue(this.value, this._content)} }, /** * update form values