Git Product home page Git Product logo

vue-country-code's Introduction

vue-country-code

Country Code Select with Vue.

Checkout Demo at Github pages.

Installation

  • yarn:
      yarn add vue-country-code
  • npm:
      npm i --save vue-country-code

Usage

  • Install as a global component:

    import Vue from "vue";
    import VueCountryCode from "vue-country-code";
    
    Vue.use(VueCountryCode);
  • In your component:

    <template>
    ...
       <vue-country-code
                      @onSelect="onSelect"
                      <!-- optional -->
                      :preferredCountries="['vn', 'us', 'gb']">
       </vue-country-code>
    ...
    <template>
    <script>
    export default {
      data() {
        return {
        };
      },
      methods: {
         onSelect({name, iso2, dialCode}) {
           console.log(name, iso2, dialCode);
         },
      },
    }
    </script>
  • Manual Trigger:

    <template>
    ...
     <vue-country-code
                    ref="vcc"
                    @onSelect="onSelect"
     </vue-country-code>
     <button @click="manualTrigger">Manual Trigger</button>
    ...
    <template>
    <script>
    export default {
    data() {
      return {
      };
    },
    methods: {
       onSelect({name, iso2, dialCode}) {
         console.log(name, iso2, dialCode);
       },
       manualTrigger() {
         this.$refs.vcc.manualDropdown();
       }
    },
    }
    </script>

Props

Property value Type Default value Description
defaultCountry string '' Default country, will override the country fetched from IP address of user
disabledFetchingCountry Boolean false Disable fetching current country based on IP address of user
enabledCountryCode Boolean false Enable country code in the input
enabledFlags Boolean true Enable flags in the input
preferredCountries Array [] Preferred countries list, will be on top of the dropdown. ie ['AU', 'BR']
onlyCountries Array [] List of countries will be shown on the dropdown. ie ['AU', 'BR']
ignoredCountries Array [] List of countries will NOT be shown on the dropdown. ie ['AU', 'BR']
dropdownOptions Object { disabledDialCode: false } Options for dropdown, supporting disabledDialCode

Events

Property value Arguments Description
onSelect Object Fires when the input changes with the argument is the object includes { name, iso2, dialCode }

Highlights & Credits

Demo Usage

# install dependencies
$ yarn/npm install

# compile demo and start serve for development
$ yarn/npm dev

# build
$ yarn/npm build

Made by Mon.

vue-country-code's People

Contributors

hantrongbinh avatar dependabot[bot] avatar wilpat 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.