feat: json 无数据时显示 placeholder (#1326)

This commit is contained in:
吴多益 2021-01-07 23:24:16 +08:00 committed by GitHub
parent 36b3f6d9ac
commit 57e908f910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,6 +156,7 @@ export class JSONField extends React.Component<JSONProps, object> {
jsonTheme,
classnames: cx,
hideRoot,
placeholder,
source
} = this.props;
@ -176,13 +177,17 @@ export class JSONField extends React.Component<JSONProps, object> {
return (
<div className={cx('JsonField', className)}>
<JSONTree
data={data}
theme={theme}
shouldExpandNode={this.shouldExpandNode}
valueRenderer={this.valueRenderer}
hideRoot={hideRoot}
/>
{typeof value === 'undefined' || value === null ? (
placeholder
) : (
<JSONTree
data={data}
theme={theme}
shouldExpandNode={this.shouldExpandNode}
valueRenderer={this.valueRenderer}
hideRoot={hideRoot}
/>
)}
</div>
);
}