npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clx-element-china-area-data

v1.0.1

Published

[![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/dw/element-china-area-data) ![GitHub top language](https://img.shields.io/github/languages/top/Plor

Downloads

2

Readme

Element UI 中国省市区级联数据

npm npm GitHub top language npm bundle size GitHub

演示效果 gif

20230508-093525

v6 改动

  1. 改用全新脚手架构建,同时支持 CommonJS 和 ESM modules
  2. 去掉了 provinceAndCityDataPlus/regionDataPlus/TextToCode
  3. CodeToText 修改为 codeToText
  4. 添加了纯汉字的数据对象 pcTextArr 和 pcaTextArr
  5. 不再支持港澳台,使用新的数据源https://github.com/modood/Administrative-divisions-of-China

旧版本 v5.0.2

文档地址

安装

npm install element-china-area-data -S

在线示例

import 使用

import {
  provinceAndCityData,
  pcTextArr,
  regionData,
  pcaTextArr,
  codeToText,
} from "element-china-area-data";
  1. provinceAndCityData省市二级联动数据,汉字+code
  2. regionData省市区三级联动数据
  3. pcTextArr省市联动数据,纯汉字
  4. pcaTextArr省市区联动数据,纯汉字
  5. codeToText是个大对象,属性是区域码,属性值是汉字 用法例如:codeToText['110000']输出北京市
  • 省市二级联动:

    <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>
  • 省市二级联动,纯汉字:

    <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: []
          }
        },
      }
    </script>
  • 省市区三级联动

    <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>
  • 省市区三级联动,纯汉字

    <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>

script 引入

<script src="https://unpkg.com/[email protected]/dist/element-china-area-data.iife.js"></script>
<script>
  new Vue({
    el: "#app",
    data: function () {
      return {
        codeToText: elementChinaAreaData.codeToText,
        provinceAndCityData: elementChinaAreaData.provinceAndCityData,
        pcTextArr: elementChinaAreaData.pcTextArr,
        regionData: elementChinaAreaData.regionData,
        pcaTextArr: elementChinaAreaData.pcaTextArr,
        selectedOptions1: ["11", "110101"],
        selectedOptions2: ["12", "1201", "120101"],
        selectedOptions3: ["北京市", "朝阳区"],
        selectedOptions4: ["北京市", "市辖区", "朝阳区"],
      };
    },
  });
</script>

数据来源

Administrative-divisions-of-China

开发测试命令

  • dev - starts dev server
  • build - generates the following bundles: CommonJS (.cjs) ESM (.mjs) and IIFE (.iife.js). The name of bundle isautomatically taken from package.json name property
  • test - starts vitest and runs all tests
  • test:coverage - starts vitest and run all tests with code coverage report
  • lint:scripts - lint .ts files with eslint
  • lint:styles - lint .css and .scss files with stylelint
  • format:scripts - format .ts, .html and .json files with prettier
  • format:styles - format .cs and .scss files with stylelint
  • format - format all with prettier and stylelint
  • prepare - script for setting up husky pre-commit hook
  • uninstall-husky - script for removing husky from repository