docs: Add import on demand link.

This commit is contained in:
Wei Zhu 2017-12-04 14:57:30 +08:00
parent 5f35a69858
commit 6172f773ac
2 changed files with 4 additions and 30 deletions

View File

@ -40,7 +40,7 @@
## 安装 ## 安装
```bash ```bash
npm install antd npm install antd --save
``` ```
## 示例 ## 示例
@ -56,7 +56,7 @@ ReactDOM.render(<DatePicker />, mountNode);
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less' import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
``` ```
按需加载可通过此写法 `import DatePicker from 'antd/lib/date-picker'` 或使用 Babel 插件 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import),或使用 TypeScript 插件 [ts-import-plugin](https://github.com/Brooooooklyn/ts-import-plugin)。 你也可以[按需加载组件](https://ant.design/docs/react/getting-started-cn#按需加载)。
## TypeScript ## TypeScript

View File

@ -40,7 +40,7 @@ An enterprise-class UI design language and React-based implementation.
## Install ## Install
```bash ```bash
npm install antd npm install antd --save
``` ```
## Usage ## Usage
@ -56,33 +56,7 @@ And import style manually:
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less' import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
``` ```
### Use modularized antd Or [import components on demand](https://ant.design/docs/react/getting-started#Import-on-Demand)
- Manually import
```jsx
import DatePicker from 'antd/lib/date-picker'; // for js
import 'antd/lib/date-picker/style/css'; // for css
// import 'antd/lib/date-picker/style'; // that will import less
```
- Use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)
```js
// .babelrc or babel-loader option
{
"plugins": [
["import", { "libraryName": "antd", "style": "css" }] // `style: true` for less
]
}
```
Then you can import components from antd, equivalent to import manually below.
```jsx
// import js and css modularly, parsed by babel-plugin-import
import { DatePicker } from 'antd';
```
### TypeScript ### TypeScript