mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
7fd093bd0a
* docs: add general components TS demo * docs: add layout components TS demo * docs: add navigation components TS demo * docs: add data entry components TS demo * chore(deps): add types for qs * docs: add data display TS demo * docs: add feedback components TS demo * docs: add other components TS demo * chore(deps): add types * docs: unified demo code style * docs: fix lint error * docs: add demo TS type * docs: fix demo TS type * test: update snapshot * docs: fix TS demo * feat: update Rate character type * docs: fix lint error * feat: update Rate character type * feat: update Rate character type
1.9 KiB
1.9 KiB
order | title | ||||
---|---|---|---|---|---|
3 |
|
zh-CN
自定义全局组件的 Empty 样式。
en-US
Use ConfigProvider set global Empty style.
import React, { useState } from 'react';
import {
ConfigProvider,
Switch,
Divider,
TreeSelect,
Select,
Cascader,
Transfer,
Table,
List,
} from 'antd';
import { SmileOutlined } from '@ant-design/icons';
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;