Empty空状态
空状态时的展示占位图。
何时使用#
当目前没有数据时,用于显式的用户提示。
初始化场景时的引导创建流程。
代码演示
暂无数据
TypeScript
JavaScript
import { Empty } from 'infrad';
const App: React.FC = () => <Empty />;
export default App;
No Application Found
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_APP" />, mountNode);
暂无数据
TypeScript
JavaScript
import { Empty } from 'infrad';
const App: React.FC = () => <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
export default App;
No Data
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_DATA" />, mountNode);
No Logs Found
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_LOG" />, mountNode);
No Operation Records
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_RECORDS" />, mountNode);
Your search does not match any results
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_RESULTS" />, mountNode);
You hava not received any ratings
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_RATINGS" />, mountNode);
No Image Found
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_IMAGE" />, mountNode);
No Premission
import { Empty } from 'infrad';
ReactDOM.render(<Empty type="NO_PREMISSION" />, mountNode);
Select
TreeSelect
Cascader
Transfer
0 项
No Data
0 项
No Data
Table
Name | Age |
---|---|
暂无数据 |
List
暂无数据
TypeScript
JavaScript
import { SmileOutlined } from 'infra-design-icons';
import {
Cascader,
ConfigProvider,
Divider,
List,
Select,
Switch,
Table,
Transfer,
TreeSelect,
} from 'infrad';
import React, { useState } from 'react';
const customizeRenderEmpty = () => (
<div style={{ textAlign: 'center' }}>
<SmileOutlined style={{ fontSize: 20 }} />
<p>Data Not Found</p>
</div>
);
const style = { width: 200 };
const App: React.FC = () => {
const [customize, setCustomize] = useState(false);
return (
<div>
<Switch
unCheckedChildren="default"
checkedChildren="customize"
checked={customize}
onChange={val => {
setCustomize(val);
}}
/>
<Divider />
<ConfigProvider renderEmpty={customize ? customizeRenderEmpty : undefined}>
<div className="config-provider">
<h4>Select</h4>
<Select style={style} />
<h4>TreeSelect</h4>
<TreeSelect style={style} treeData={[]} />
<h4>Cascader</h4>
<Cascader style={style} options={[]} showSearch />
<h4>Transfer</h4>
<Transfer />
<h4>Table</h4>
<Table
style={{ marginTop: 8 }}
columns={[
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
]}
/>
<h4>List</h4>
<List />
</div>
</ConfigProvider>
</div>
);
};
export default App;
Customize Description
TypeScript
JavaScript
import { Button, Empty } from 'infrad';
import React from 'react';
const App: React.FC = () => (
<Empty
image="https://gw.alipayobjects.com/zos/antfincdn/ZHrcdLPrvN/empty.svg"
imageStyle={{
height: 60,
}}
description={
<span>
Customize <a href="#API">Description</a>
</span>
}
>
<Button type="primary">Create Now</Button>
</Empty>
);
export default App;
TypeScript
JavaScript
import { Empty } from 'infrad';
const App: React.FC = () => <Empty description={false} />;
export default App;
API#
<Empty>
<Button>创建</Button>
</Empty>
参数 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
description | 自定义描述内容 | ReactNode | - | |
image | 设置显示图片,为 string 时表示自定义图片地址。 | ReactNode | Empty.PRESENTED_IMAGE_DEFAULT | |
imageStyle | 图片样式 | CSSProperties | - | |
type | 多种类型的空状态,优先级比 image 低 | String | 'NO_APP' | 'NO_DATA' | 'NO_LOG' | 'NO_RECORDS' | 'NO_RESULTS' | 'NO_RATINGS' | 'NO_IMAGE' | 'NO_PREMISSION' |
内置图片#
Empty.PRESENTED_IMAGE_SIMPLE
Empty.PRESENTED_IMAGE_DEFAULT