Giter Site home page Giter Site logo

queeniemar / vue-region-picker Goto Github PK

View Code? Open in Web Editor NEW

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

0.0 1.0 0.0 228 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.43% JavaScript 52.64% Vue 42.84% Smarty 3.09%

vue-region-picker's Introduction

#vue-region-picker Build Status npm

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

Demo

HERE

Requirements

Install

  • npm
$ npm install vue-region-picker --save

Usage

  • html
<body>
  <region-picker
    :province.sync="province"
    :city.sync="city"
    :district.sync="district">
  </region-picker>
</body>
  • javascript
import Vue from 'vue'
import RegionPicker from 'vue-region-picker'
import REGION_DATA from 'vue-region-picker/data'

Vue.use(RegionPicker, {
  region: REGION_DATA
})

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 'vue-region-picker/data'

RegionPicker.region = REGION_DATA

new Vue({
  el: 'body',

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

  components: { RegionPicker }
})

Properties

province

  • Type: Number/String
  • Required: true
  • twoWay: true

Bind province. You can set the initial value or not. Set the initial value by (number)code or (string)name.

city

  • Type: Number/String
  • Required: true
  • twoWay: true

Bind city. You can set the initial value or not. Set the initial value by (number)code or (string)name.

district

  • Type: Number/String
  • twoWay: true

Bind district. You can set the initial value or not. Set the initial value by (number)code or (string)name.

placeholder

  • Type: Object
  • Default: { province: '请选择', city: '请选择', district: '请选择'}

Show placeholder.

auto

  • Type: Boolean
  • Default: false

If empty option will automatically hide.

required

  • Type: Boolean
  • Default: false

Required if the option is not empty.

completed

  • Type: Boolean
  • Default: false

Allow the return value is complete, it contains an array of code(number) and name(string).

e.g. { "district": [ 440105, "海珠区" ], "city": [ 440100, "广州市" ], "province": [ 440000, "广东省" ] }

disabled

  • Type: Boolean
  • Default: false

disabled attribute

two-select

  • Type: Boolean
  • Default: false

If true, display only province and city

Slot

  • province
  • city
  • district

example

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

Development

$ npm run dev

Testing and Building

$ npm test
$ npm run dist

License

WTFPL

vue-region-picker's People

Contributors

qingwei-li avatar

Watchers

 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.