mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
优化函数名
This commit is contained in:
parent
b99eda9a93
commit
efc11f66de
@ -29,7 +29,7 @@ import {
|
||||
guid,
|
||||
isObject,
|
||||
isEmpty,
|
||||
iterateChildren
|
||||
mapObject
|
||||
} from '../utils/helper';
|
||||
import { IComboStore } from "./combo";
|
||||
import isEqual = require('lodash/isEqual');
|
||||
@ -182,7 +182,7 @@ export const FormStore = ServiceStore
|
||||
}
|
||||
|
||||
function trimValues() {
|
||||
let data = iterateChildren(self.data, (item:any) => typeof item === 'string' ? item.trim() : item);
|
||||
let data = mapObject(self.data, (item:any) => typeof item === 'string' ? item.trim() : item);
|
||||
self.updateData(data);
|
||||
}
|
||||
|
||||
|
@ -726,14 +726,14 @@ export function chainFunctions(...fns:Array<(...args:Array<any>) => void>):(...a
|
||||
}
|
||||
}
|
||||
|
||||
export function iterateChildren(value: any, fn: Function): any {
|
||||
export function mapObject(value: any, fn: Function): any {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(item => iterateChildren(item, fn));
|
||||
return value.map(item => mapObject(item, fn));
|
||||
}
|
||||
if (isObject(value)) {
|
||||
let tmpValue = {...value};
|
||||
Object.keys(tmpValue).forEach(key => {
|
||||
(tmpValue as PlainObject)[key] = iterateChildren((tmpValue as PlainObject)[key], fn);
|
||||
(tmpValue as PlainObject)[key] = mapObject((tmpValue as PlainObject)[key], fn);
|
||||
});
|
||||
return tmpValue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user