@ytfee/district
v0.0.4
Published
中国行政区划解析
Downloads
1
Readme
使用方法
yarn add @ytfee/district
or npm install @ytfee/district
- broswer
import district from '@ytfee/district'
console.log(district.getData())
or
import { getData, getDetail, format } from '@ytfee/district'
console.log(getData())
- node
const district = require('@ytfee/district')
console.log(district.getData())
or
const { getData, getDetail, format } = require('@ytfee/district')
console.log(getData())
- getData将返回常规行政区划编码原始数据
- getDetail传入原始数据及任意编码返回所有详细信息
interface PropString {
[propName: string]: string
}
interface DetailResult {
provinces: PropString
province: string
provinceName: string
citys: PropString
city: string
cityName: string
countys: PropString
county: string
countyName: string
}
测试用例
getData().then(async ({result, message}) => {
console.log('0 getData', message, 'output test.json')
console.log('1----------> province', getDetail(result, {province: '110000'}))
console.log('2----------> city', getDetail(result, {city: '140300'}))
console.log('3----------> city 中山市', getDetail(result, {city: '442000'}))
console.log('4----------> county', getDetail(result, {county: '451102'}))
console.log('5----------> county 中山市', getDetail(result, {county: '442000'}))
console.log('6----------> code 省', getDetail(result, {code: '110000'}))
console.log('7----------> code 市', getDetail(result, {code: '140300'}))
console.log('8----------> code 区', getDetail(result, {code: '451102'}))
console.log('9----------> code 中山市', getDetail(result, {code: '442000'}))
const formatData = format(result, 'elementui2')
})
基础规范
- src/main.js 为入口文件,导入所有方法
- src/_aBb*.js 下横杠驼峰为 公共方法
- src/aBb.js 驼峰格式为 工具方法
- src/AaBb.js 大驼峰格式为 工具类
发布规范
- 必须通过eslint和jest校验
- npm采用语义化版本,共三位,以’.’隔开,从左至右依次代表:主版本(major)、次要版本(minor)、补丁版本(patch)。
npm version patch
npm version minor
npm version major