2.0.3 • Published 7 years ago

vue2-twzipcode v2.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Vue2-TWzipcode

Rewrite jQuery-TWzipcode in Vue2

This Repo was refactored from CasperLaiTW.

Screenshot

pic

Example

Not yet, but you can see Vue 1 example by CasperLaiTW.

Installation

$ yarn add vue2-twzipcode

Usage

<template>
  <twzipcode
    :class-names="{county: 'form-control', district: 'form-control', zipcode: 'form-control'}"
    default-zipcode="403"
    ref="twzipcode"
    @update="result"
  >
  </twzipcode>
</template>

<script>
  import Twzipcode from 'vue2-twzipcode';

  export default {
    methods: {
      result({ zipcode, county, district }) {
        console.log(zipcode, county, district);
      }
    },
    components: {
      Twzipcode
    },
  };
</script>

Get Values

If you don't want to use event binding, you can just use refs instead.

const {county, district, zipcode } = app.$refs.twzipcode;

console.log(county, district, zipcode);  // 台中市, 西區, 403

Props

PropTypeDefaultExample
namesObject{county: 'county', district: 'district', zipcode: 'zipcode'}{county: 'my-county', district: 'my-district', zipcode: 'my-zipcode'}
classNamesObject{county: '', district: '', zipcode: ''}{county: 'form-control', district: 'form-control', zipcode: 'form-control'}
focusObjectnullfocus="{ '台北市': [ '松山區', '大同區' ] }"
defaultCountyString'基隆市'default-county="台中市"
defaultDistrictString''default-district="西區"
defaultZipcodeString''default-zipcode="403"
  1. Using props to component, notice kebab-case
  2. defaultZipcode is highest priority than defaultCounty and defaultDistrict. So if you using both, will be ignored defaultCounty and defaultDistrict props.
  3. focus will limit the selection by { COUNTY_NAME: [ DISTRICT_NAME1, DISTRICT_NAME2... ] }, and make zipcode readonly.
  4. If district list in focus is an empty Array, it will use default list instead.

Contributing

All contributions (in the form on pull requests, issues and feature-requests) are welcome.

License

Licenced under the MIT License (MIT). Please see the license file for more information.

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago