Giter VIP home page Giter VIP logo

athiwatp / vue-region-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qingwei-li/vue-region-picker

0.0 2.0 0.0 254 KB

A Vue.js Component for picking provinces, cities and districts of China. (Vue 省市区三级联动组件)

Home Page: http://qingwei-li.github.io/vue-region-picker/

License: Do What The F*ck You Want To Public License

Makefile 1.24% JavaScript 91.45% Smarty 7.31%

vue-region-picker's Introduction

vue-region-picker

Build Status npm

A Vue.js Component for picking provinces, cities and districts of China.

Supports both Vue 1.x and 2.0!

Demo

Requirements

Area data

Install

$ npm install vue-region-picker china-area-data --save

Usage

html

<body>
  <!-- Vue1.x -->
  <region-picker
    :province.sync="province"
    :city.sync="city"
    :district.sync="district">
  </region-picker>
  <!-- Vue2 -->
  <region-picker
    :province="province"
    :city="city"
    :district="district"
    @onchange="change">
  </region-picker>
</body>

javascript

import Vue from 'vue'
import RegionPicker from 'vue-region-picker'
import REGION_DATA from 'china-area-data'

Vue.use(RegionPicker, {
  region: REGION_DATA,
  vueVersion: 1 // or 2, default 1
})

// Vue1.x
new Vue({
  el: 'body',

  data () {
    return {
      province: '广东', // you can set initial value or not.
      city: 440100, // by code or name.
      district: ''
    }
  }
})

Or

import Vue from 'vue'
import { RegionPicker } from 'vue-region-picker'
import REGION_DATA from 'china-area-data'

RegionPicker.region = REGION_DATA
// RegionPicker.vueVersion = 1 // or 2, default 1

new Vue({
  el: 'body',

  data () {
    return {
      province: '广东', // you can set initial value or not.
      city: 440100, // by code or name.
      district: ''
    }
  },

  components: { RegionPicker }
})

Options

name description Type default Value
region region data Object -
vueVersion vue version, 1 or 2 Number 1

Props

name description Type default Value
province Bind province. You can set the initial value or not. Set the initial value by (number)code or (string)name. Number, String
city Bind city. You can set the initial value or not. Set the initial value by (number)code or (string)name. Number, String
district Bind district. You can set the initial value or not. Set the initial value by (number)code or (string)name. Number, String
placeholder Placeholder Object { province: '请选择', city: '请选择', district: '请选择'}
auto If empty option will automatically hide. Boolean false
required Required if the option is not empty. Boolean false
completed Allow the return value is complete, it contains an array of code(number) and name(string). e.g. { "district": [ 440105, "海珠区" ], "city": [ 440100, "广州市" ], "province": [ 440000, "广东省" ] } Boolean false
disabled disabled Boolean false
two-select If true, display only province and city Boolean false
onchange selected callback Function

Slots

name description
province province label
city city label
district district label
<region-picker
  :province.sync="address.province"
  :city.sync="address.city"
  :district.sync="address.district">
  <span slot="province">省份</span>
  <span slot="city">城市</span>
  <span slot="district">地区</span>
</region-picker>

Development

$ npm i cooking -g
$ npm run dev

Testing and Building

$ npm test
$ npm run dist

License

WTFPL

vue-region-picker's People

Contributors

qingwei-li avatar brookqin avatar

Watchers

James Cloos avatar athiwatp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.