Browse Source

📃 docs: 补充文档 (#41268)

补充文档

Co-authored-by: chenxiaokun <chenxiaokun@didiglobal.com>
3.x-stable
竹雨 2 years ago
committed by GitHub
parent
commit
272ac40bba
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      components/modal/index.en-US.md
  2. 21
      components/modal/index.zh-CN.md

21
components/modal/index.en-US.md

@ -110,3 +110,24 @@ browserHistory.listen(() => {
Modal.destroyAll(); Modal.destroyAll();
}); });
``` ```
## FAQ
### Why I can not access context, redux, ConfigProvider `locale/prefixCls` in Modal.xxx?
antd will dynamic create React instance by `ReactDOM.render` when call Modal methods. Whose context is different with origin code located context.
You can try the following ways to solve the problem
set [@ant-prefix](https://github.com/ant-design/ant-design/blob/2c6c789e3a9356f96c47aea0083f5a15538315cf/components/style/themes/default.less#L7):`'ant-prefix': 'antd3'`
```js
import { Modal } from 'antd';
// use
Modal.confirm({
title: 'hello world',
// must use the '-modal' suffix
prefixCls: 'antd3-modal',
});
```

21
components/modal/index.zh-CN.md

@ -113,3 +113,24 @@ browserHistory.listen(() => {
Modal.destroyAll(); Modal.destroyAll();
}); });
``` ```
## FAQ
### 为什么 Modal 方法不能获取 context、redux、的内容和 ConfigProvider `locale/prefixCls` 配置?
直接调用 Modal 方法,antd 会通过 `ReactDOM.render` 动态创建新的 React 实体。其 context 与当前代码所在 context 并不相同,因而无法获取 context 信息。
你可以用以下的方法解决这个问题
设置 [@ant-prefix](https://github.com/ant-design/ant-design/blob/2c6c789e3a9356f96c47aea0083f5a15538315cf/components/style/themes/default.less#L7):`'ant-prefix': 'antd3'`
```js
import { Modal } from 'antd';
// 使用
Modal.confirm({
title: 'hello world',
// 必须带上 '-modal' 后缀
prefixCls: 'antd3-modal',
});
```

Loading…
Cancel
Save