mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
docs: Add import on demand link.
This commit is contained in:
parent
5f35a69858
commit
6172f773ac
@ -40,7 +40,7 @@
|
||||
## 安装
|
||||
|
||||
```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 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
|
||||
|
||||
|
30
README.md
30
README.md
@ -40,7 +40,7 @@ An enterprise-class UI design language and React-based implementation.
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install antd
|
||||
npm install antd --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
@ -56,33 +56,7 @@ And import style manually:
|
||||
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
|
||||
```
|
||||
|
||||
### Use modularized antd
|
||||
|
||||
- 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';
|
||||
```
|
||||
Or [import components on demand](https://ant.design/docs/react/getting-started#Import-on-Demand)
|
||||
|
||||
### TypeScript
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user