mapping 对于 boolean 的处理不太合理 (#1690)

This commit is contained in:
liaoxuezhi 2021-03-23 12:47:13 +08:00 committed by GitHub
parent b7c5da3da5
commit 45343a7ffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,17 +54,19 @@ export class MappingField extends React.Component<MappingProps, object> {
<span className="text-muted">{placeholder}</span>
);
key = typeof key === 'string' ? key.trim() : key; // trim 一下,干掉一些空白字符。
key =
typeof key === 'string'
? key.trim()
: key === true
? '1'
: key === false
? '0'
: key; // trim 一下,干掉一些空白字符。
if (typeof key !== 'undefined' && map && (map[key] ?? map['*'])) {
viewValue = render(
'tpl',
map[key] ??
(key === true && map['1']
? map['1']
: key === false && map['0']
? map['0']
: map['*']) // 兼容平台旧用法:即 value 为 true 时映射 1 ,为 false 时映射 0
map[key] ?? map['*'] // 兼容平台旧用法:即 value 为 true 时映射 1 ,为 false 时映射 0
);
}