paul-thebaud / v-phone-input

International and accessible phone input for Vuetify 3 and Vue 3.
https://paul-thebaud.github.io/v-phone-input/
MIT License
65 stars 6 forks source link

Event update:country type question #13

Closed ydedev closed 1 year ago

ydedev commented 1 year ago

Expected Behavior

get

CountryIso2 --

Actual Behavior

get string

Steps to Reproduce the Problem

  1. The event update:country did not get the CountryIso2 type, but actually got the string type
<script setup>
import { ref } from 'vue';
import {
    getCountryCodeForRegionCode,
} from 'awesome-phonenumber'

const phone = ref('');
let phoneRef = ref()
function submit(){
    console.log(phone)
    console.log(phoneRef.value)
}

function countryFunc(e){
    console.log(e)
    console.log(getCountryCodeForRegionCode( e ))
}

</script>

<template>

  <div style="margin: 0 auto; width: 430px;">
    <v-phone-input ref="phoneRef" v-model="phone"  @update:country="countryFunc"/>
    <v-btn @click="submit" block class="mt-2">Submit</v-btn>
  </div>

</template>

Events

Name | Type | Description -- | -- | -- update:modelValue | string | Emitted when the country or phone is updated with the E164 formatted phone number. update:country | CountryIso2 | Emitted when the country is updated with the selected country.

Specifications

paul-thebaud commented 1 year ago

Hello, Sorry, but I don't understand your question. Could you rephrase in a simple maner it please?

ydedev commented 1 year ago

In the readme description, the update:country event type value is CountryIso2, and the actual value obtained is a string.

paul-thebaud commented 1 year ago

OK. CountryIso2 is a type alias just representing a string of 2 chars. See the following Typescript types.