- 组件总览
- 通用
- 布局
- 导航
- 数据录入
- 数据展示
- 反馈
- 其他
空状态时的展示占位图。
import React from 'react';
import { Empty } from 'antd';
const App: React.FC = () => <Empty />;
export default App;
import React from 'react';
import { Empty } from 'antd';
const App: React.FC = () => <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
export default App;
import React from 'react';
import { Button, Empty } from 'antd';
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;
Data Not Found
Data Not Found
Name | Age |
---|---|
Data Not Found |
Data Not Found
import React, { useState } from 'react';
import { SmileOutlined } from '@ant-design/icons';
import {
Cascader,
ConfigProvider,
Divider,
List,
Select,
Space,
Switch,
Table,
Transfer,
TreeSelect,
} from 'antd';
const customizeRenderEmpty = () => (
<div style={{ textAlign: 'center' }}>
<SmileOutlined style={{ fontSize: 20 }} />
<p>Data Not Found</p>
</div>
);
const style: React.CSSProperties = { width: 200 };
const App: React.FC = () => {
const [customize, setCustomize] = useState(true);
return (
<>
<Switch
unCheckedChildren="default"
checkedChildren="customize"
checked={customize}
onChange={setCustomize}
/>
<Divider />
<ConfigProvider renderEmpty={customize ? customizeRenderEmpty : undefined}>
<Space direction="vertical" style={{ width: '100%' }}>
<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 />
</Space>
</ConfigProvider>
</>
);
};
export default App;
import React from 'react';
import { Empty } from 'antd';
const App: React.FC = () => <Empty description={false} />;
export default App;
<Empty><Button>创建</Button></Empty>
参数 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
description | 自定义描述内容 | ReactNode | - | |
image | 设置显示图片,为 string 时表示自定义图片地址。 | ReactNode | Empty.PRESENTED_IMAGE_DEFAULT | |
imageStyle | 图片样式 | CSSProperties | - |
Empty.PRESENTED_IMAGE_SIMPLE
Empty.PRESENTED_IMAGE_DEFAULT