You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
---
|
|
|
|
category: Components
|
|
|
|
subtitle: 全局化配置
|
|
|
|
cols: 1
|
|
|
|
type: 其他
|
|
|
|
title: ConfigProvider
|
|
|
|
---
|
|
|
|
|
|
|
|
为组件提供统一的全局化配置。
|
|
|
|
|
|
|
|
## 使用
|
|
|
|
|
|
|
|
ConfigProvider 使用 React 的 [context](https://facebook.github.io/react/docs/context.html) 特性,只需在应用外围包裹一次即可全局生效。
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { ConfigProvider } from 'antd';
|
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConfigProvider {...yourConfig}>
|
|
|
|
<App />
|
|
|
|
</ConfigProvider>
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
|
|
|
### Content Security Policy
|
|
|
|
|
|
|
|
部分组件为了支持波纹效果,使用了动态样式。如果开启了 Content Security Policy (CSP),你可以通过 `csp` 属性来进行配置:
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
<ConfigProvider csp={{ nonce: 'YourNonceCode' }}>
|
|
|
|
<Button>My Button</Button>
|
|
|
|
</ConfigProvider>
|
|
|
|
```
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
| --- | --- | --- | --- |
|
|
|
|
| customizeRenderEmpty | 自定义组件空状态。参考 [空状态](/components/empty/) | Function(componentName: string): ReactNode | - |
|
|
|
|
| getPopupContainer | 弹出框(Select, Tooltip, Menu 等等)渲染父节点,默认渲染到 body 上。 | Function(triggerNode) | () => document.body |
|
|
|
|
| prefixCls | 设置统一样式前缀 | string | ant |
|