2018-12-26 16:01:00 +08:00
|
|
|
---
|
|
|
|
order: 3
|
|
|
|
title:
|
|
|
|
zh-CN: 全局化配置
|
|
|
|
en-US: ConfigProvider
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
自定义全局组件的 Empty 样式。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Use ConfigProvider set global Empty style.
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import {
|
2019-05-07 14:57:32 +08:00
|
|
|
ConfigProvider,
|
|
|
|
Switch,
|
|
|
|
Divider,
|
|
|
|
TreeSelect,
|
|
|
|
Select,
|
|
|
|
Cascader,
|
2018-12-26 16:01:00 +08:00
|
|
|
Transfer,
|
2019-05-07 14:57:32 +08:00
|
|
|
Table,
|
|
|
|
List,
|
2018-12-26 16:01:00 +08:00
|
|
|
} from 'antd';
|
2019-11-28 12:34:33 +08:00
|
|
|
import { SmileOutlined } from '@ant-design/icons';
|
2018-12-26 16:01:00 +08:00
|
|
|
|
|
|
|
const customizeRenderEmpty = () => (
|
|
|
|
<div style={{ textAlign: 'center' }}>
|
2019-11-28 12:34:33 +08:00
|
|
|
<SmileOutlined style={{ fontSize: 20 }} />
|
2018-12-26 16:01:00 +08:00
|
|
|
<p>Data Not Found</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
const style = { width: 200 };
|
|
|
|
|
|
|
|
class Demo extends React.Component {
|
|
|
|
state = {
|
|
|
|
customize: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { customize } = this.state;
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Switch
|
|
|
|
unCheckedChildren="default"
|
|
|
|
checkedChildren="customize"
|
|
|
|
checked={customize}
|
2019-05-07 14:57:32 +08:00
|
|
|
onChange={val => {
|
2018-12-26 16:01:00 +08:00
|
|
|
this.setState({ customize: val });
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Divider />
|
|
|
|
|
|
|
|
<ConfigProvider renderEmpty={customize && customizeRenderEmpty}>
|
|
|
|
<div className="config-provider">
|
2020-08-22 15:24:44 +08:00
|
|
|
<h4>Select</h4>
|
2018-12-26 16:01:00 +08:00
|
|
|
<Select style={style} />
|
|
|
|
|
2020-08-22 15:24:44 +08:00
|
|
|
<h4>TreeSelect</h4>
|
2018-12-26 16:01:00 +08:00
|
|
|
<TreeSelect style={style} treeData={[]} />
|
|
|
|
|
2020-08-22 15:24:44 +08:00
|
|
|
<h4>Cascader</h4>
|
2018-12-26 16:01:00 +08:00
|
|
|
<Cascader style={style} options={[]} showSearch />
|
|
|
|
|
2020-08-22 15:24:44 +08:00
|
|
|
<h4>Transfer</h4>
|
2018-12-26 16:01:00 +08:00
|
|
|
<Transfer />
|
|
|
|
|
2020-08-22 15:24:44 +08:00
|
|
|
<h4>Table</h4>
|
2018-12-26 16:01:00 +08:00
|
|
|
<Table
|
|
|
|
style={{ marginTop: 8 }}
|
|
|
|
columns={[
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age',
|
|
|
|
dataIndex: 'age',
|
|
|
|
key: 'age',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
|
2020-08-22 15:24:44 +08:00
|
|
|
<h4>List</h4>
|
2018-12-26 16:01:00 +08:00
|
|
|
<List />
|
|
|
|
</div>
|
|
|
|
</ConfigProvider>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
```
|
|
|
|
|
|
|
|
<style>
|
2020-08-22 15:24:44 +08:00
|
|
|
.code-box-demo .config-provider h4 {
|
2018-12-26 16:01:00 +08:00
|
|
|
font-size: inherit;
|
|
|
|
margin: 16px 0 8px 0;
|
|
|
|
}
|
2019-05-07 14:57:32 +08:00
|
|
|
</style>
|