Skip to content

Commit f6aecac

Browse files
authored
How to get selected country (#28)
* How to get selected country * country output added * 1.1.4
1 parent 9c06665 commit f6aecac

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

dev/serve.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
<div id="app">
33
<div class="row">
44
<div class="col-3 offset-3 q-mt-lg">
5-
<vue3-q-tel-input use-icon v-model:tel="input" searchText="Search using code/country" dense filled default-country="de" />
5+
<vue3-q-tel-input use-icon v-model:tel="input" searchText="Search using code/country" dense filled default-country="de" @country="c => (country = c)" />
66
</div>
77
</div>
88
<div>entered telephone number : {{ input }}</div>
9+
<div>
10+
Country :
11+
<pre>{{ JSON.stringify(country, null, 4) }}</pre>
12+
</div>
913
</div>
1014
</template>
1115

@@ -21,6 +25,7 @@ export default defineComponent({
2125
data() {
2226
return {
2327
input: '',
28+
country: null,
2429
};
2530
},
2631
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue3-q-tel-input",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Vue 3 telephone input implemented over Quasar framework",
55
"scripts": {
66
"serve": "vue-cli-service serve dev/serve.ts",

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ _example_
8989
</vue3-q-tel-input>
9090
```
9191

92-
All the slots that are supported in [quasar select](https://quasar.dev/vue-components/select) field are available in the plugin as country select control slots with prefix `cs-`.
92+
All the slots that are supported in [quasar select](https://quasar.dev/vue-components/select) field are available in the plugin as country select control slots with prefix `cs-`.
9393

9494
_example_
9595

@@ -117,7 +117,7 @@ _example_
117117
| ---------------- | ------- | -------- | ------------------------------------------------------------------------------------- |
118118
| required | Boolean | No | Shows error validation when the field is empty |
119119
| search-text | String | No | The label for the search field inside the country dropdown |
120-
| search-icon | String | No | Set the icon for the search field to something else |
120+
| search-icon | String | No | Set the icon for the search field to something else |
121121
| default-country | String | No | The default country to load. eg: us, ae, de, in etc. |
122122
| dropdown-options | Obejct | No | The props availalbe for the [Quasar Select](https://quasar.dev/vue-components/select) |
123123
| eager-validate | Boolean | No | Set to true if the validation needs not be run on loading |
@@ -130,3 +130,4 @@ _example_
130130
| update:tel | string | Triggers when an update is made to the model value |
131131
| input | string | Triggers when the input value changes |
132132
| error | boolean | true when the input is invalid and false when valid |
133+
| country | Country | Gets back the object information of a country |

src/component/Index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default defineComponent({
5151
dense: { type: Boolean, default: () => false },
5252
disable: { type: Boolean, default: () => false },
5353
},
54-
emits: ['update:tel', 'input', 'error'],
54+
emits: ['update:tel', 'input', 'error', 'country'],
5555
setup(_, { slots }) {
5656
const country: Ref<Country> = ref(getDefault() as Country);
5757
const old_country: Ref<Country | undefined> = ref(undefined);
@@ -97,6 +97,7 @@ export default defineComponent({
9797
country: {
9898
immediate: true,
9999
handler() {
100+
this.$emit('country', this.country);
100101
this?.$nextTick(() => {
101102
this.old_country = this.country;
102103
});

0 commit comments

Comments
 (0)