doc: add Chinese faq and fix typo (#12292)

* doc: add Chinese faq and fix typo

* fix typo

* make some adjustments to sentencing

* adjustments
This commit is contained in:
Wendell 2018-09-19 14:00:31 +08:00 committed by 偏右
parent b0078a2d17
commit ceb3435af2
2 changed files with 61 additions and 63 deletions

View File

@ -9,7 +9,7 @@ Search in the questions about React first: https://reactfaq.site .
### Are you going to provide Vue(etc...) edition?
No, but [the LICENSE of ant-design](https://github.com/ant-design/ant-design/blob/master/LICENSE) is MIT. So, you can try to implement it with ant-design's [style](https://github.com/ant-design/ant-design/tree/master/style), like: [ant-design-vue](https://github.com/vueComponent/ant-design-vue) [vue-beauty)](https://github.com/FE-Driver/vue-beauty) or [antue](https://github.com/zzuu666/antue).
No, but [the LICENSE of ant-design](https://github.com/ant-design/ant-design/blob/master/LICENSE) is MIT. So, you can try to implement it with ant-design's [style](https://github.com/ant-design/ant-design/tree/master/style), like: [ant-design-vue](https://github.com/vueComponent/ant-design-vue) [vue-beauty](https://github.com/FE-Driver/vue-beauty) or [antue](https://github.com/zzuu666/antue).
### Are you going to provide Sass/Stylus(etc...) style file?
@ -94,7 +94,7 @@ Please check [And Design Mobile](http://mobile.ant.design) for details. `antd` h
### Does `antd` supply standalone files like 'react' do?
Yep, you can [import `antd` with script tag](https://ant.design/docs/react/install?locale=en-US#Import-in-Browser). But we recommend use `npm` to import `antd`, it is simple and ease to maintain.
Yep, you can [import `antd` with script tag](https://ant.design/docs/react/install?locale=en-US#Import-in-Browser). But we recommend use `npm` to import `antd`, it is simple and easy to maintain.
### I can't visit `icon` in my network environment.

View File

@ -3,115 +3,113 @@ order: 9
title: FAQ
---
Search in the questions about React first: https://reactfaq.site .
有问题请先问 Reacthttps://reactfaq.site 。
---
### Are you going to provide Vue(etc...) edition?
### 你们会提供 Vue 版本的 Ant Design 吗?
No, but [the LICENSE of ant-design](https://github.com/ant-design/ant-design/blob/master/LICENSE) is MIT. So, you can try to implement it with ant-design's [style](https://github.com/ant-design/ant-design/tree/master/style), like: [ant-design-vue](https://github.com/vueComponent/ant-design-vue) [vue-beauty)](https://github.com/FE-Driver/vue-beauty) or [antue](https://github.com/zzuu666/antue).
不,但是 [ant-design 基于 MIT 协议开源](https://github.com/ant-design/ant-design/blob/master/LICENSE),所以你可以尝试用 ant-design 的[样式](https://github.com/ant-design/ant-design/tree/master/style)去实现一套,例如:[ant-design-vue](https://github.com/vueComponent/ant-design-vue) [vue-beauty](https://github.com/FE-Driver/vue-beauty) 或者 [antue](https://github.com/zzuu666/antue)。
### Are you going to provide Sass/Stylus(etc...) style file?
### 你们会提供 Sass/Stylus 等格式的样式文件吗?
No, actually, you can convert Less to Sass/Stylus(etc...) with tools (which you can Google).
不。事实上你可以使用工具(请自行 Google将 Less 转换成 Sass/Stylus 等。
### `Select Dropdown DatePicker TimePicker Popover Popconfirm` will disappear when I click another popup component inside it, How to resolve it?
### 当我点击 `Select Dropdown DatePicker TimePicker Popover Popconfirm` 内的另一个 popup 组件时它会消失,如何解决?
Use `<Select getPopupContainer={trigger => trigger.parentNode}>` to render component inside Popover. (Or other getXxxxContainer props)
使用 `<Select getPopupContainer={trigger => trigger.parentNode}>` 来在 Popover 中渲染组件,或者使用其他的 getXxxxContainer 参数。
https://ant.design/components/select/#Select-props
related issue: [#3487](https://github.com/ant-design/ant-design/issues/3487) [#3438](https://github.com/ant-design/ant-design/issues/3438)
相关 issue[#3487](https://github.com/ant-design/ant-design/issues/3487) [#3438](https://github.com/ant-design/ant-design/issues/3438)
### `Select Dropdown DatePicker TimePicker Popover Popconfirm` will scroll with page?
### `Select Dropdown DatePicker TimePicker Popover Popconfirm` 会跟随滚动条上下移动?
Use `<Select getPopupContainer={trigger => trigger.parentNode}>` to render component inside the scroll area. (Or other getXxxxContainer props).
使用 `<Select getPopupContainer={trigger => trigger.parentNode}>` 来将组件渲染到滚动区域内,或者使用其他的 getXxxxContainer 参数。
https://ant.design/components/select/#Select-props
related issue: [#3487](https://github.com/ant-design/ant-design/issues/3487) [#3438](https://github.com/ant-design/ant-design/issues/3438)
相关 issue[#3487](https://github.com/ant-design/ant-design/issues/3487) [#3438](https://github.com/ant-design/ant-design/issues/3438)
### How to modify default theme of Ant Design?
### 如何修改 Ant Design 的默认主题?
See: https://ant.design/docs/react/customize-theme .
参考https://ant.design/docs/react/customize-theme 。
### Would you supply other themes?
### 你们会提供其他主题吗?
No, we follow Ant Design specification. https://github.com/ant-design/ant-design/issues/1241
不,我们遵守 Ant Design 设计规范。https://github.com/ant-design/ant-design/issues/1241
### How to modify `Menu`/`Button`(etc...)'s style?
### 如何修改 Ant Design 组件的默认样式?
You can override its style. But we don't recommend to do so. antd is not only a set of React components but also a design specification.
你可以覆盖它们的样式但是我们不推荐这么做。antd 是一系列 React 组件,但同样是一套设计规范。
### I just want to use `Menu`/`Button`(etc...), but it seems that I have to import the whole antd and its style.
### 我只想使用 `Menu`/`Button` 等,但似乎我必须 import 整个 antd 和它的样式文件。
Try [babel-plugin-import](https://github.com/ant-design/babel-plugin-import), or import what you need in this way:
试试 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import),或者用下面这种方式来按需加载:
```jsx
import Menu from 'antd/lib/menu';
import 'antd/lib/button/style/css';
```
or (ES6 way with tree shaking):
或者ES6 支持的 tree shaking 方式):
```jsx
import { Menu, Breadcrumb, Icon } from 'antd';
```
### How to optimize momentjs bundle size with webpack?
### 如何配置 webpack 以优化 momentjs 的打包大小?
See: https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
参考:https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
### It doesn't work when I change `defaultValue` dynamically.
### 当我动态改变 `defaultValue` 的时候它并没有生效。
The `defaultXxxx` (like `defaultValue`) of `Input`/`Select`(etc...) only works in first render. It is a specification of React, please read [React's documentation](https://facebook.github.io/react/docs/forms.html#controlled-components).
`Input`/`Select` 等的 `defaultXxxx`(例如 `defaultValue`)只有在第一次渲染的时候有效,这是 React 的规范,请阅读 [React 的文档](https://reactjs.org/docs/forms.html#controlled-components)。
### I set the `value` of `Input`/`Select`(etc...), and then, it cannot be changed by user's action.
### 当我设置了 `Input`/`Select` 等的 `value` 时它就无法修改了。
Try `defaultValue` or `onChange` to change `value`, and please read [React's documentation](https://facebook.github.io/react/docs/forms.html#controlled-components).
尝试使用 `defaultValue``onChange` 来改变 `value`,请参考 [React 的文档](https://reactjs.org/docs/forms.html#controlled-components)。
### antd override my global styles!
### antd 覆盖了我的全局样式!
Yes, antd is designed to develop a complete background application, we override some global styles for styling convenience and it can't be removed now. More info trace https://github.com/ant-design/ant-design/issues/4331 .
是的antd 在设计的时候就是用来开发一个完整的应用的,为了方便,我们覆盖了一些全局样式,现在还不能移除,想要了解更多请追踪这个 issuehttps://github.com/ant-design/ant-design/issues/4331 ,或者参考这个教程 [How to avoid modifying global styles?](docs/react/customize-theme#How-to-avoid-modifying-global-styles-?)
Or follow instruction in [How to avoid modifying global styles?](docs/react/customize-theme#How-to-avoid-modifying-global-styles-?)
### 我没法安装 `antd``antd` 的依赖,顺便提一句,我在中国大陆。
### I cannot install `antd` and `antd`'s dependencies(etc...). FYI, I live in China mainland.
那啥,试试 [cnpm](http://npm.taobao.org/)。
Long live the Girl Friend Wall! And try [cnpm](http://npm.taobao.org/).
### 我在 package.json 里将 `dependencies.antd` 添加到了 git repository 中,但是没有用。
### I set `dependencies.antd` as git repository in package.json, but it doesn't work.
当然没用了,请使用 npm 安装 `antd`
Yes, please install `antd` with npm.
### `message``notification` 是小写的,但是其他的组件都是首字母大写的,这是手滑吗?
### `message` and `notification` is lower case, but other components are capitalized. Typo?
不,因为 `message` 是一个函数,而不是一个 React 组件。
No, as `message` is just a function, not a React Component.
### `antd` 在移动端体验不佳。
### `antd` doesn't work well in mobile.
请浏览 [And Design Mobile](http://mobile.ant.design) 以了解详情,`antd` 并非针对移动端设计。你可以试试 [react-component](https://github.com/react-component/),其中带有 'm-' 'rn-' 前缀的库是为移动端设计的。
Please check [And Design Mobile](http://mobile.ant.design) for details. `antd` has not been optimized to do so. You may try [react-component](https://github.com/react-component/), those repositories which start with 'm-' 'rn-' are designed for mobile.
### `antd` 会像 `React` 那样提供单文件引入吗?
### Does `antd` supply standalone files like 'react' do?
是的,[你可以用 script 标签引入](https://ant.design/docs/react/install?locale=en-US#Import-in-Browser)。但是我们推荐使用 `npm` 来引入 `antd`,这样维护起来更简单方便。
Yep, you can [import `antd` with script tag](https://ant.design/docs/react/install?locale=en-US#Import-in-Browser). But we recommend use `npm` to import `antd`, it is simple and ease to maintain.
### 在我的网络环境下没法获取到 `icon` 文件。
### I can't visit `icon` in my network environment.
你应该自行部署 iconfont 文件到你的网络上,参考这个[例子](https://github.com/ant-design/antd-init/tree/7c1a33cadb98f2fd8688fe527dd7f98215b9bced/examples/local-iconfont)。 [#1070](https://github.com/ant-design/ant-design/issues/1070)
You should deploy the iconfont files to your network by following this [example](https://github.com/ant-design/antd-init/tree/7c1a33cadb98f2fd8688fe527dd7f98215b9bced/examples/local-iconfont). [#1070](https://github.com/ant-design/ant-design/issues/1070)
在 3.9.x 版本后,[我们会使用 svg 图标](/components/icon#svg-icons),你就不用担心本地部署 iconfont 的问题了!
After 3.9.x [we are using svg icon](/components/icon#svg-icons) so you don't need to deploy iconfont locally any more!
### 如何拓展 antd 的组件?
### How to extend antd's components?
如果你需要一些 antd 没有包含的功能,你可以尝试通过 [HOC](https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775) 拓展 antd 的组件。 [更多](https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750#.eeu8q01s1)
If you need some features which should not be included in antd, try to extend antd's component with [HOC](https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775). [more](https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750#.eeu8q01s1)
### 如何正确的拼写 Ant Design
### How to spell Ant Design correctly?
- ✅ **Ant Design**:用空格分隔的首字母大写单词,指代设计语言
- ✅ **antd**:全小写,指代 React UI 组件库
- ✅ **Ant Design**: Capitalized with space, for the design language
- ✅ **antd**: all lowercase, for the React UI library
Here are some typical wrong examples:
下面是一些典型的错误例子:
- ❌ AntD
- ❌ antD
@ -121,40 +119,40 @@ Here are some typical wrong examples:
- ❌ antdesign
- ❌ Antdesign
### Do you guys have any channel for donation? like PayPal or Alipay.
### 你们有接受捐助的渠道吗,比如支付宝或者微信支付?
No yet.
还没有。
### Why not?
### 为什么?
Alibaba will pay us.
马爸爸会付给我们钱。
---
## Errors & Warnings
## 错误和警告
Here are some errors & warnings that you may meet while using antd, but most of them are not bugs of antd.
这里是一些你在使用 antd 的过程中可能会遇到的错误和警告,但是其中一些并不是 antd 的 bug。
### Adjacent JSX elements must be wrapped in an enclosing tag
An [answer from StackOverflow](http://stackoverflow.com/questions/25034994/how-to-correctly-wrap-few-td-tags-for-jsxtransformer), and please read [React's documentation](http://facebook.github.io/react/docs/displaying-data.html#components-are-just-like-functions).
这里有一篇[来自 StackOverflow 的回答](http://stackoverflow.com/questions/25034994/how-to-correctly-wrap-few-td-tags-for-jsxtransformer),另外请阅读 [React 的文档](http://facebook.github.io/react/docs/displaying-data.html#components-are-just-like-functions)
### React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components)
Please make sure that you import `antd`'s components correctly. Read the corresponding documentation of the `antd`'s version which you use. And pay attention to typo.
请确保你正确引入了 `antd` 的组件。参考 `antd` 相应组件的文档,注意你代码中的 typo。
### rm is not recognized as an internal or external command
Please read this [issue](https://github.com/ant-design/ant-design/issues/650#issuecomment-164966511), or try Linux/Unix.
请阅读这个 [issue](https://github.com/ant-design/ant-design/issues/650#issuecomment-164966511),或者试试 Linux/Unix。
### Failed propType: Invalid prop `AAA` of type `BBB` supplied to `CCC`, expected `DDD`. Check the render method of `EEE`.
Please read the corresponding documentation of the `antd`'s version which you use, and make sure that you pass value with correct type to `antd`'s components,
请阅读你正在使用版本的 `antd` 的文档,确保你传递给 `antd` 组件的参数类型正确。
### Unknown option: xxx/package.json.presets
An [answer from Stack Overflow](http://stackoverflow.com/questions/33685365/unknown-option-babelrc-presets).
这里有一篇[来自 StackOverflow 的回答](http://stackoverflow.com/questions/33685365/unknown-option-babelrc-presets)可以参考。
### Invariant Violation: findComponentRoot(...): Unable to find element.
You may import React twice. Set React & ReactDOM as external, if you are using webpack, See: [#525](https://github.com/ant-design/ant-design/issues/525). If you are using others(browserify, etc...), please read its documentation and find options which can set React & ReactDOM as external.
你或许引入了 React 两次。如果你使用 webpack请将 React & ReactDOM 设置为 external参见[#525](https://github.com/ant-design/ant-design/issues/525)。如果你使用其他工具browserify 等),请阅读它们的文档并将 React & ReactDOM 设置为 external。