mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
parent
548f3cccfd
commit
5e969c5ee4
@ -18,15 +18,22 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) {
|
||||
const arr: Array<any> = [];
|
||||
Object.keys(value).forEach(key => {
|
||||
const valueType = typeof value[key];
|
||||
arr.push({
|
||||
key: key || '',
|
||||
value:
|
||||
valueType === 'string' ||
|
||||
valueType === 'number' ||
|
||||
valueType === 'boolean'
|
||||
? value[key]
|
||||
: JSON.stringify(value[key])
|
||||
});
|
||||
if (key.endsWith('___tmp')) {
|
||||
arr.push({
|
||||
key: key.replace('___tmp', ''),
|
||||
value: ''
|
||||
});
|
||||
} else {
|
||||
arr.push({
|
||||
key: key || '',
|
||||
value:
|
||||
valueType === 'string' ||
|
||||
valueType === 'number' ||
|
||||
valueType === 'boolean'
|
||||
? value[key]
|
||||
: JSON.stringify(value[key])
|
||||
});
|
||||
}
|
||||
});
|
||||
return arr;
|
||||
},
|
||||
@ -41,7 +48,12 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) {
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
} catch (e) {}
|
||||
obj[key] = value;
|
||||
// 如果先输入了 a 作为 key,想输入 aa 的时候会先进入这里,导致无法输入 aa,因此当遇到 key 相同的时候加个 ___tmp 后缀
|
||||
if (key in obj && typeof value === 'undefined') {
|
||||
obj[key + '___tmp'] = '';
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user