mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 21:08:55 +08:00
fix(amis-core): 修复select组件中一个未判空导致的渲染错误 (#6937)
* fix(amis-core): 修复select组件中一个未判空导致的渲染错误 * fix(amis-core): 修复select组件中一个未判空导致的渲染错误
This commit is contained in:
parent
0f63e1bbbc
commit
a36502b311
@ -52,32 +52,37 @@ export function normalizeOptions(
|
||||
return option;
|
||||
});
|
||||
} else if (Array.isArray(options as Options)) {
|
||||
return (options as Options).map(item => {
|
||||
const value = item && item[valueField];
|
||||
return (options as Options)
|
||||
.filter(item => item !== null && item !== undefined)
|
||||
.map(item => {
|
||||
const value = item && item[valueField];
|
||||
const idx =
|
||||
value !== undefined && !item.children
|
||||
? share.values.indexOf(value)
|
||||
: -1;
|
||||
|
||||
const idx =
|
||||
value !== undefined && !item.children
|
||||
? share.values.indexOf(value)
|
||||
: -1;
|
||||
if (~idx) {
|
||||
return share.options[idx];
|
||||
}
|
||||
|
||||
if (~idx) {
|
||||
return share.options[idx];
|
||||
}
|
||||
const option = {
|
||||
...item,
|
||||
[valueField]: value
|
||||
};
|
||||
|
||||
const option = {
|
||||
...item,
|
||||
[valueField]: value
|
||||
};
|
||||
if (typeof option.children !== 'undefined') {
|
||||
option.children = normalizeOptions(
|
||||
option.children,
|
||||
share,
|
||||
valueField
|
||||
);
|
||||
} else if (value !== undefined) {
|
||||
share.values.push(value);
|
||||
share.options.push(option);
|
||||
}
|
||||
|
||||
if (typeof option.children !== 'undefined') {
|
||||
option.children = normalizeOptions(option.children, share, valueField);
|
||||
} else if (value !== undefined) {
|
||||
share.values.push(value);
|
||||
share.options.push(option);
|
||||
}
|
||||
|
||||
return option;
|
||||
});
|
||||
return option;
|
||||
});
|
||||
} else if (isPlainObject(options)) {
|
||||
return Object.keys(options).map(key => {
|
||||
const idx = share.values.indexOf(key);
|
||||
|
Loading…
Reference in New Issue
Block a user