Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dwqs committed Apr 18, 2018
1 parent 9a73690 commit e2a469a
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,38 @@
## Installation
Install the pkg with npm:
```
// v3之前的版本
npm i --save react-area-linkage
// v3及之后的版本
npm i --save react-area-linkage area-data
```

or yarn

```
yarn add react-area-linkage
// v3之前的版本
yarn add react-area-linkage
// v3及之后的版本
yarn add react-area-linkage area-data
```

## Usage
```
import React from 'react';
import ReactDOM from 'react-dom';
import { pca, pcaa } from 'area-data'; // v3 or higher
import 'react-area-linkage/dist/index.css'; // v2 or higher
import { AreaSelect, AreaCascader } from 'react-area-linkage';
// basic
<AreaSelect onChange={this.selectedChange} />
<AreaCascader onChange={this.selectedChange} />
<AreaSelect onChange={this.selectedChange} data={pca} />
<AreaCascader onChange={this.selectedChange} data={pcaa}/>
//setting
<AreaSelect type='all' level={2} onChange={this.selectedChange} />
<AreaCascader type='all' onChange={this.selectedChange} level={2} />
<AreaSelect type='all' level={2} data={pcaa} onChange={this.selectedChange} />
<AreaCascader type='all' onChange={this.selectedChange} level={1} data={pcaa} />
```

More demo to visit [here](https://dwqs.github.io/react-area-linkage/).
Expand Down Expand Up @@ -56,16 +66,16 @@ npm i babel-plugin-on-demand-import -D

```
import 'react-area-linkage/dist/index.css'; // v2 or higher
import pcaa from 'area-data/pcaa';
// Only import AreaCascader component
import { AreaCascader } from 'react-area-linkage';
<AreaCascader onChange={this.selectedChange}></AreaCascader>
<AreaCascader onChange={this.selectedChange} level={2} data={pcaa}></AreaCascader>
// Only import AreaSelect component
import { AreaSelect } from 'react-area-linkage';
<AreaSelect onChange={this.selectedChange}></AreaSelect>
<AreaSelect onChange={this.selectedChange} level={1} data={pcaa}></AreaSelect>
```

## 属性
Expand All @@ -79,6 +89,7 @@ import { AreaSelect } from 'react-area-linkage';
| defaultArea | Array | - | [] | 设置默认值(值类型数据需统一,要么全是文本,要么全是区域代码) |
| onChange | Function | - | - | 选择项改变时的回调 |
| disabled | Boolean | - | false | 是否禁用 |
| data | Object | - | - | 地区数据(v3需要传入) |

> v2 仅支持省市区联动,即 v2 不再支持 level 的值为 3
Expand All @@ -93,6 +104,7 @@ import { AreaSelect } from 'react-area-linkage';
| onChange | Function | - | - | 选择项改变时的回调 |
| disabled | Boolean | - | false | 是否禁用 |
| separator | String | - | '/' | 显示选中文本的分隔符 |
| data | Object | - | - | 地区数据(v3需要传入) |

## Related Project
* [vue-area-linkage](https://github.com/dwqs/vue-area-linkage/)
Expand Down

0 comments on commit e2a469a

Please sign in to comment.