V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
Terry05

v-region - 基于 Vue2 的中国行政区划选择器

  •  
  •   Terry05 ·
    TerryZ · Jun 11, 2018 · 6475 views
    This topic created in 2882 days ago, the information mentioned may be changed or developed.

    v-region - 基于 Vue2 的中国行政区划选择器

    v-region

    npm npm npm

    实例、文档

    请浏览

    插件预览

    基础表单模式

    ui

    选择器模式

    base



    安装插件

    npm install v-region --save
    

    在入口文件 main.js 中导入插件

    import Vue from 'vue'
    import vRegion from 'v-region';
    Vue.use(vRegion);
    

    在你的页面中使用(基础模式)

    template code

    <template>
        <v-region @values="regionChange" class="form-control"></v-region>
    </template>
    

    script code

    export default {
        methods:{
            //receive selected region data
            regionChange(data){
                console.log(data);
            }
        }
    };
    

    Data Source

    region data com from repo: mumuy/data_location

    7 replies    2018-06-13 14:27:32 +08:00
    chairuosen
        1
    chairuosen  
       Jun 11, 2018
    老铁,参数只能传 true false,老外文论如何都用不了,那命名应该叫 china-region 啊,
    IvanLi127
        2
    IvanLi127  
       Jun 11, 2018 via Android
    楼上说的在理
    Terry05
        3
    Terry05  
    OP
       Jun 11, 2018
    @chairuosen 行政区划显然做不了世界通用的,虽然是只提供中国的行政区划,但插件命名加个 china 没啥意思,也不简洁
    zjuster
        4
    zjuster  
       Jun 11, 2018
    @Terry05 国际地区编码有 ISO 标准的,除了特例的 case (有争议 etc ),都可以有固定层级。
    网上流传最多的一份是 QQ 的一份 文件,你搜下应该可以找到,缺点是好久没更新了。
    zjuster
        5
    zjuster  
       Jun 11, 2018
    @Terry05 ISO3166
    Terry05
        6
    Terry05  
    OP
       Jun 12, 2018
    @zjuster 其实做这个插件要考虑的还有一点是数据量的问题,我在这个插件里使用的 @mumuy 的数据,它的数据结构已经是最简洁,最节省容量的数据了,找过一些网上的另它的行政区划的数据,一个节点就有很多字段

    省 /市 /区(县) 的数据合在一起只有 78K,再加上县一级就硬是多了 1.78M ;其它国家的我数据没有去研究过,就单单中国的行政区划数据,就做不了标准模式,一个直辖市就弄得很麻烦

    即然是集成了中国区的数据,也就没有打算兼容,如果其它国家的数据没有直辖市之类的结构,那就很简单,后期只需要开放自定义数据源即可
    MikeFeng
        7
    MikeFeng  
       Jun 13, 2018
    数据不完整,广西河池宜州区 下面没有内容
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   758 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 21:40 · PVG 05:40 · LAX 14:40 · JFK 17:40
    ♥ Do have faith in what you're doing.