Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
wxy committed Apr 28, 2023
1 parent 0f34238 commit 807e727
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 109 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## [6.0.0] - 2023-04-28

0. 改用全新脚手架构建,同时支持 CommonJS 和 ESM modules
1. 去掉了provinceAndCityDataPlus/regionDataPlus/TextToCode
2. CodeToText修改为codeToText
3. 添加了纯汉字的数据对象pcTextArr和pcaTextArr
4. 去掉了港澳台地区的数据
0. 改用全新脚手架构建,同时支持 CommonJS 和 ESM modules
1. 去掉了 provinceAndCityDataPlus/regionDataPlus/TextToCode
2. CodeToText 修改为 codeToText
3. 添加了纯汉字的数据对象 pcTextArr 和 pcaTextArr
4. 去掉了港澳台地区的数据
197 changes: 103 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,136 +2,145 @@

[![npm](https://img.shields.io/npm/v/element-china-area-data.svg)](https://www.npmjs.com/package/element-china-area-data) [![npm](https://img.shields.io/npm/dt/element-china-area-data.svg)](https://www.npmjs.com/package/element-china-area-data)

## v6改动

0. 改用全新脚手架构建,同时支持 CommonJS 和 ESM modules
1. 去掉了provinceAndCityDataPlus/regionDataPlus/TextToCode
2. CodeToText修改为codeToText
3. 添加了纯汉字的数据对象pcTextArr和pcaTextArr
4. 不再支持港澳台
## 旧版本v5.0.2
## v6 改动

0. 改用全新脚手架构建,同时支持 CommonJS 和 ESM modules
1. 去掉了 provinceAndCityDataPlus/regionDataPlus/TextToCode
2. CodeToText 修改为 codeToText
3. 添加了纯汉字的数据对象 pcTextArr 和 pcaTextArr
4. 不再支持港澳台

## 旧版本 v5.0.2

[文档地址](./V5.MD)

## 安装

`npm install element-china-area-data -S`
`npm install element-china-area-data -S`

[在线示例](https://plortinus.github.io/element-china-area-data/index.html)

## 使用

```js
import { provinceAndCityData, pcTextArr, regionData, pcaTextArr, codeToText } from 'element-china-area-data'
import {
provinceAndCityData,
pcTextArr,
regionData,
pcaTextArr,
codeToText,
} from "element-china-area-data";
```

1. `provinceAndCityData`省市二级联动数据,汉字+code
2. `regionData`省市区三级联动数据
3. `pcTextArr`省市联动数据,纯汉字
4. `pcaTextArr`省市区联动数据,纯汉字
5. `codeToText`是个大对象,属性是区域码,属性值是汉字 用法例如:`codeToText['110000']`输出`北京市`


* 省市二级联动:
```js
<template>
<div id="app">
<el-cascader
size="large"
:options="provinceAndCityData"
v-model="selectedOptions">
</el-cascader>
</div>
</template>

<script>
import { provinceAndCityData } from 'element-china-area-data'
export default {
data () {
return {
provinceAndCityData,
selectedOptions: []
}
},
}
</script>
```

* 省市二级联动,纯汉字:
```js
<template>
<div id="app">
<el-cascader
size="large"
:options="pcTextArr"
v-model="selectedOptions">
</el-cascader>
</div>
</template>
<script>
import { pcTextArr } from 'element-china-area-data'
export default {
data () {
return {
pcTextArr,
selectedOptions: []
}
},
1. `provinceAndCityData`省市二级联动数据,汉字+code
2. `regionData`省市区三级联动数据
3. `pcTextArr`省市联动数据,纯汉字
4. `pcaTextArr`省市区联动数据,纯汉字
5. `codeToText`是个大对象,属性是区域码,属性值是汉字 用法例如:`codeToText['110000']`输出`北京市`

- 省市二级联动:

```js
<template>
<div id="app">
<el-cascader
size="large"
:options="provinceAndCityData"
v-model="selectedOptions">
</el-cascader>
</div>
</template>

<script>
import { provinceAndCityData } from 'element-china-area-data'
export default {
data () {
return {
provinceAndCityData,
selectedOptions: []
}
</script>
```
},
}
</script>
```

* 省市区三级联动
- 省市二级联动,纯汉字:

```js
<template>
<div id="app">
<el-cascader
size="large"
:options="regionData"
:options="pcTextArr"
v-model="selectedOptions">
</el-cascader>
</div>
</template>
<script>
import { regionData } from 'element-china-area-data'
import { pcTextArr } from 'element-china-area-data'
export default {
data () {
return {
regionData,
pcTextArr,
selectedOptions: []
}
},
}
</script>
```

* 省市区三级联动,纯汉字

```js
<template>
<div id="app">
<el-cascader
size="large"
:options="pcaTextArr"
v-model="selectedOptions">
</el-cascader>
</div>
</template>
<script>
import { pcaTextArr } from 'element-china-area-data'
export default {
data () {
return {
pcaTextArr,
selectedOptions: []
}
},
}
</script>
```
- 省市区三级联动

```js
<template>
<div id="app">
<el-cascader
size="large"
:options="regionData"
v-model="selectedOptions">
</el-cascader>
</div>
</template>
<script>
import { regionData } from 'element-china-area-data'
export default {
data () {
return {
regionData,
selectedOptions: []
}
},
}
</script>
```

- 省市区三级联动,纯汉字

```js
<template>
<div id="app">
<el-cascader
size="large"
:options="pcaTextArr"
v-model="selectedOptions">
</el-cascader>
</div>
</template>
<script>
import { pcaTextArr } from 'element-china-area-data'
export default {
data () {
return {
pcaTextArr,
selectedOptions: []
}
},
}
</script>
```

## 数据来源

Expand Down
20 changes: 10 additions & 10 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@
<script src="../dist/element-china-area-data.iife.js"></script>
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script >
<script>
new Vue({
el: '#app',
data: function() {
el: "#app",
data: function () {
return {
visible: false,
codeToText: elementChinaAreaData.codeToText,
provinceAndCityData: elementChinaAreaData.provinceAndCityData,
pcTextArr: elementChinaAreaData.pcTextArr,
regionData: elementChinaAreaData.regionData,
pcaTextArr: elementChinaAreaData.pcaTextArr,
selectedOptions1: ['11', '110101'],
selectedOptions2: ['12', '1201', '120101'],
selectedOptions3: ['北京市', '朝阳区'],
selectedOptions4: ['北京市', '市辖区', '朝阳区']
}
}
})
selectedOptions1: ["11", "110101"],
selectedOptions2: ["12", "1201", "120101"],
selectedOptions3: ["北京市", "朝阳区"],
selectedOptions4: ["北京市", "市辖区", "朝阳区"],
};
},
});
</script>
</html>

0 comments on commit 807e727

Please sign in to comment.