CitySelect 中国,省,市,区县,乡联动选择
省市区数据
https://gist.github.com/afc163/7582f35654fd03d5be7009444345ea17
https://www.npmjs.com/package/china-division
CitySelect
<CitySelect
// value={['53', '5329', '532901', '532901102']} // 'code'
value={['云南省', '大理白族自治州', '大理市', '大理镇']}// 'name'
onChange={(values: any[]) => console.log('city', values)}
// mode='name'
// gutter={0}
// level={2} // 省/市
/>
Cascader 省市区级联
import { Cascader } from 'antd';
import options from './cascader-address-options';
function CitySelect() {
return (
<Cascader
options={options}
showSearch
placeholder="请选择地址"
/>
)
}
export default CitySelect;
cascader-address-options.js
china-division 数据源 https://github.com/pansyjs/china-division
import provinces from 'china-division/dist/provinces.json';
import cities from 'china-division/dist/cities.json';
import areas from 'china-division/dist/areas.json';
areas.forEach((area) => {
const matchCity = cities.filter(city => city.code === area.cityCode)[0];
if (matchCity) {
matchCity.children = matchCity.children || [];
matchCity.children.push({
label: area.name,
value: area.code,
});
}
});
cities.forEach((city) => {
const matchProvince = provinces.filter(province => province.code === city.provinceCode)[0];
if (matchProvince) {
matchProvince.children = matchProvince.children || [];
matchProvince.children.push({
label: city.name,
value: city.code,
children: city.children,
});
}
});
const options = provinces.map(province => ({
label: province.name,
value: province.code,
children: province.children,
}));
export default options;
中国省市区数据
中华人民共和国行政区划(五级):省级、地级、县级、乡级和村级
https://github.com/modood/Administrative-divisions-of-China
- 省份、直辖市、自治区;二级联动数据 pc-code.json
- 省份、城市、区县;三级联动数据 pca-code.json
- 省份、城市、区县、乡镇、街道;四级联动数据 pcas-code.json
- 村级 村委会居委会;五级联动
推荐 pcas-code.json,以上json数据都带 code编码
国家统计局区域代码
http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm
mysql五级行政区域数据
https://github.com/kakuilan/china_area_mysql
china_regions
https://github.com/wecatch/china_regions
最全最新中国省,市,地区 json 及 sql 数据
iview-area