mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
fix: Form开启trimValues时会将File字段错误转换问题 (#5162)
This commit is contained in:
parent
8ca2a10b4a
commit
f93d002c28
@ -1350,10 +1350,32 @@ export function chainEvents(props: any, schema: any) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function mapObject(value: any, fn: Function): any {
|
||||
export function mapObject(
|
||||
value: any,
|
||||
fn: Function,
|
||||
skipFn?: (value: any) => boolean
|
||||
): any {
|
||||
// 如果value值满足skipFn条件则不做map操作
|
||||
skipFn =
|
||||
skipFn && typeof skipFn === 'function'
|
||||
? skipFn
|
||||
: (value: any): boolean => {
|
||||
// File类型处理之后会变成plain object
|
||||
if (value instanceof File) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (!!skipFn(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(item => mapObject(item, fn));
|
||||
}
|
||||
|
||||
if (isObject(value)) {
|
||||
let tmpValue = {...value};
|
||||
Object.keys(tmpValue).forEach(key => {
|
||||
|
Loading…
Reference in New Issue
Block a user