-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDemo.vue
51 lines (45 loc) · 990 Bytes
/
Demo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
<div class="wrapper">
<h1>Vue Google Maps Zipcode Input</h1>
<div>
<!-- <p>Locations are logged to console once selected</p> -->
<br>
<Zipcode @selected="zipcodeSelected" country="FR">
<input v-model="zipcode" type="text" ref="autocomplete" placeholder="zipcode">
</Zipcode>
<p>{{ location }}</p>
</div>
</div>
</template>
<style lang="stylus" scoped>
.wrapper
font-family sans-serif
width 80vw
margin auto
margin-top 20px
</style>
<script>
import Zipcode from './Zipcode.vue';
export default {
data() {
return {
zipcode: '',
location: '',
}
},
methods: {
zipcodeSelected(location) {
this.$set(this.$data, 'zipcode', '');
this.$set(this.$data, 'location', JSON.stringify({
city: location.city,
zipcode: location.zipcode,
country: location.country,
}));
console.log(location);
},
},
components: {
Zipcode,
}
}
</script>