• Stars
    star
    477
  • Rank 92,112 (Top 2 %)
  • Language Vue
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

省市区联动选择: https://dwqs.github.io/vue-area-linkage/

npm-version license

vue-area-linkage

省市区联动选择. 组合数据来源:area-data

Installation

Install the pkg with npm:

// v5之前的版本
npm i --save vue-area-linkage

// v5及之后的版本
npm i --save vue-area-linkage area-data

or yarn

// v5之前的版本
yarn add vue-area-linkage

// v5及之后的版本
yarn add vue-area-linkage area-data

Usage

import Vue from 'vue';
import { pca, pcaa } from 'area-data'; // v5 or higher
import 'vue-area-linkage/dist/index.css'; // v2 or higher
import VueAreaLinkage from 'vue-area-linkage';

Vue.use(VueAreaLinkage)
// v5之前的版本
<area-select v-model="selected"></area-select>
<area-cascader v-model="selected2"></area-cascader>

// v5及之后的版本
<area-select v-model="selected" :data="pca"></area-select> // 省市
// 省市区:<area-select v-model="selected" :data="pcaa"></area-select>
<area-cascader v-model="selected2" :data="pca"></area-cascader> // 省市
// 省市区:<area-cascader v-model="selected2" :data="pcaa"></area-cascader>

//setting
<area-select type='all' :level='2' v-model="selected" :data="pcaa"></area-select>
<area-cascader type='all' v-model="selected2" :level='1' :data="pcaa"></area-cascader>

More demo to visit here.

On Demand Import

version >= 2.1.2

安装 babel-plugin-on-demand-import:

npm i babel-plugin-on-demand-import -D

修改 .babelrc:

{
    // ...
    "plugins": [
        ["on-demand-import" {
            "libraryName": "vue-area-linkage",
            "libraryPath": "dist/lib"
        }]
    ]
}
import 'vue-area-linkage/dist/index.css'; // v2 or higher
import pcaa from 'area-data/pcaa';
// Only import AreaCascader component
import { AreaCascader } from 'vue-area-linkage';
Vue.use(AreaCascader);

<area-cascader v-model="val" level={1} :data="pcaa"></area-cascader>

// Only import AreaSelect component
import { AreaSelect } from 'vue-area-linkage';
Vue.use(AreaSelect);

<area-select v-model="val2" level={2} :data="pcaa"></area-select>

属性

area-select 组件

参数 类型 可选值 默认值 说明
type String all/code/text code 设置返回的数据格式
placeholders Array - [] 设置 placeholder text
level Number 0/1/2 1 设置联动层级(0-只选省份/1-省市联动/2-省市区联动)
size String small/medium/large medium 设置输入框的大小
disabled Boolean - false 是否禁用
data Object - - 地区数据(v5需要传入)
icon String - area-select-icon 自定义下拉小图标
disableLinkage Boolean - true 地区选择是否进行联动

v4 仅支持省市区联动,即 v4 不再支持 level 的值为 3(省市区街联动)

area-cascader 组件

参数 类型 可选值 默认值 说明
type String all/code/text code 设置返回的数据格式
placeholder String - '' 设置 placeholder text
level Number 0/1 0 设置联动层级(0-省市联动/1-省市区联动)
size String small/medium/large medium 设置输入框的大小
separator String - '-' 显示选中文本的分隔符
disabled Boolean - false 是否禁用
data Object - - 地区数据(v5需要传入)

事件

事件名 说明 参数
change 选中值发生变化时触发 目前选择的值

change 事件在 1.2.5 之后提供

Related Project

License

MIT.

More Repositories

1

blog

🐶 👏 🌟 Welcome to star
JavaScript
3,782
star
2

front-end-handbook

Front-end Developer HandBook. Read online: https://dwqs.gitbooks.io/frontenddevhandbook/content/
CSS
605
star
3

area-data

中国省市区数据(含港澳台)
JavaScript
482
star
4

vue-to-react

🛠️ 👉 Try to transform Vue component to React component
JavaScript
431
star
5

area-puppeteer

基于 puppeteer 的中国行政区域抓取爬虫
JavaScript
169
star
6

react-style-guide

A mostly reasonable approach to React and JSX
157
star
7

vue-mobx

😄 ⭐ 😇 Mobx binding for Vuejs 2.
TypeScript
110
star
8

v2-table

A simple table component based Vue 2.x: https://dwqs.github.io/v2-table/
Vue
100
star
9

js2excel

😌 😃 👿 A simple module for excel and json converts each other, which works in the browser.
TypeScript
99
star
10

v2-datepicker

A simple datepicker component based Vue 2.x: https://dwqs.github.io/v2-datepicker/
JavaScript
90
star
11

tech-read

Grab tech articles daily from UGC communities
JavaScript
77
star
12

react-native-image-viewer

A pure JavaScript image viewer component for react-native apps with pan, pinch.etc, supporting both iOS and Android.
JavaScript
67
star
13

codewars-practices

Some best practices for practice questions on codewars, update it weekly
67
star
14

react-area-linkage

省市区联动选择: https://dwqs.github.io/react-area-linkage/
JavaScript
61
star
15

react-virtual-list

A tiny virtualization list component(gzipped 6KB), supports dynamic height: https://dwqs.github.io/react-virtual-list/
JavaScript
46
star
16

vue-startup

A template with webpack 4 + vuejs 2 + + babel 7 setup for projects startup
JavaScript
43
star
17

chare

A simple CLI scaffolding for front-end projects
JavaScript
35
star
18

vue-resume

A Personal Resume Template is powered by Vue,Node.js & Webpack:http://resume.ido321.com
Vue
34
star
19

react-demos

Some react demos for myself: https://dwqs.github.io/react-demos
JavaScript
33
star
20

node-style-guide

A guide for styling your node.js / JavaScript code.
32
star
21

v2-lazy-list

A simple lazy-load list component based Vue 2.x: https://dwqs.github.io/v2-lazy-list/
JavaScript
31
star
22

mp-jithub

Mini program for Github
Vue
30
star
23

vue-typescript

A template with webpack 4 + vuejs 2 + typescript 2 setup for projects startup
TypeScript
27
star
24

revuejs

🐇 A tiny, light and handy state management for vuejs 2, writing less verbose code.
JavaScript
24
star
25

vue-toast

A toast component written with Vue, designed based on Ant Design [deprecated]
Vue
18
star
26

webpack-mpvue-startup

A template with webpack 3 + mpvue 1 setup for projects startup
JavaScript
14
star
27

beautify-scrollbar

Beautify browser's scrollbars: https://dwqs.github.io/beautify-scrollbar/index
JavaScript
13
star
28

lue

🌱 Vue and vuex based library, writing less verbose code.
JavaScript
12
star
29

mpvue-markdown-parser

A markdown parser for mpvue
JavaScript
9
star
30

nx

A hexo theme based on landscape-plus
CSS
9
star
31

babel-plugin-on-demand-import

Babel plugin for importing components on demand
JavaScript
9
star
32

react-startup

A template with webpack 4 + react 16 + react-router 4 + babel 7 setup for projects startup
JavaScript
8
star
33

chrome-extension-for-wiki

🐔 🐮 🐼 Add awesome article link to your wiki repo on github quickly./快速添加文章链接到 wiki repo 的 chrome 扩展
JavaScript
7
star
34

async-await-error-handling

Error handling friendly for async/await in ts and js
JavaScript
7
star
35

reproto

A tool for generate simple random password which contains letters, number and special characters
JavaScript
6
star
36

icons

Some interesting icon & design implemented by pure css.
5
star
37

orbithub

A chrome extensition for convenient github search
JavaScript
5
star
38

redux-actions-promise

🐰 🐱 🐻 FSA-compliant promise middleware for Redux, supports referencing dispatcher/state in action.
TypeScript
5
star
39

maoxuan

教员选集阅读笔记
5
star
40

tiny-dom-helpers

🌜 🌚 🌛 Tiny dom helpers, supports IE9 +.
JavaScript
5
star
41

scroll-on-webview

处理 webview 上的滚动
JavaScript
4
star
42

infine

A chrome extension for theme color replacement of Github
CSS
4
star
43

note

Personal note sites, write what you want, support markdown: http://note.ido321.com/
JavaScript
3
star
44

view-star-packages-on-npm

View your star packages on npmjs.com: https://dwqs.github.io/view-star-packages-on-npm
JavaScript
3
star
45

async-react-compoment

😎 👀 🙈 Async component loaded based webpack 3 for react-router 4.[unmaintained]
TypeScript
2
star
46

gitlang

Repository to list all programming languages github supports
JavaScript
2
star