XProvider全局化配置
XProvider
全局化配置
为组件提供统一的全局化配置。
使用import { XProvider } from "@ant-design/x"; |
文档 编辑此页... |
XProvider 继承了 antd 的 ConfigProvider,且为 @ant-design/x 中的组件提供全局化配置。
如果您已经使用 antd 的 ConfigProvider,请对您的代码做如下变更:
- import { ConfigProvider } from 'antd';+ import { XProvider } from '@ant-design/x';const App = () => (- <ConfigProvider>+ <XProvider><YourApp />- </ConfigProvider>+ </XProvider>);
XProvider 完全继承 antd 的 ConfigProvider, 属性参考:Antd ConfigProvider
如果您的项目使用了antd 那么需要将antd的locale合并传入XProvider
import { XProvider } from '@ant-design/x';import zhCN from 'antd/locale/zh_CN';import zhCN_X from '@ant-design/x/locale/zh_CN';<XProvider locale={{...zhCN_X,..zhCN}}><App /></XProvider>
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| bubble | 气泡组件的全局配置 | {style: React.CSSProperties; styles: Record<string, React.CSSProperties>;className: string; classNames: Record<string, string>;} | - | - |
| conversations | 会话组件的全局配置 | {style: React.CSSProperties; styles: Record<string, React.CSSProperties>;className: string; classNames: Record<string, string>;shortcutKeys: {items?: ShortcutKeys<'number'> | ShortcutKeys<number>[]}} | - | - |
| prompts | 提示集组件的全局配置 | {style: React.CSSProperties; styles: Record<string, React.CSSProperties>;className: string; classNames: Record<string, string>;} | - | - |
| sender | 输入框组件的全局配置 | {style: React.CSSProperties; styles: Record<string, React.CSSProperties>;className: string; classNames: Record<string, string>;} | - | - |
| suggestion | 建议组件的全局配置 | {style: React.CSSProperties; className: string;} | - | |
| thoughtChain | 思维链组件的全局配置 | {style: React.CSSProperties; styles: Record<string, React.CSSProperties>;className: string; classNames: Record<string, string>;} | - | - |
| actions | 操作列表组件的全局配置 | {style: React.CSSProperties; className: string;} | - | - |
type SignKeysType = {Ctrl: keyof KeyboardEvent;Alt: keyof KeyboardEvent;Meta: keyof KeyboardEvent;Shift: keyof KeyboardEvent;};type ShortcutKeys<CustomKey = number | 'number'> =| [keyof SignKeysType, keyof SignKeysType, CustomKey]| [keyof SignKeysType, CustomKey];
What are you interested in?
What's new in X?
What's AGI?
Where is the doc?
How to design a good product?
Know the well
Set the AI role
Express the feeling
How to start a new project?
Install Ant Design X
Play on the web without installing