Мне нужно очистить ввод автозаполнения Google после выбора местоположения.Я присвоил значение данных значению prop компонента, но кажется, что оно не меняется.Даже при использовании часов кажется, что ничего не происходит.
Это мой компонент InputPlace:
<template>
<label class="form-label-place" for="city">
<input class="form-control pr-5" :value="value" type="text" id="inputPlace" name="city" placeholder="Ingresa tu ciudad">
</label>
</template>
<script>
export default {
name: 'input-place',
props: {
value: ''
},
mounted() {
// Google autocomplete
const options = {
types: ['(cities)'],
componentRestrictions: {country: "PE"}
};
const places = new google.maps.places.Autocomplete(document.getElementById('inputPlace'), options);
google.maps.event.addListener(places, 'place_changed', () => {
this.$parent.placeChanged(places)
});
}
}
</script>
И вот как я использую его в виде:
<template>
...
<input-place :value="InputPlaceValue"></input-place>
</template>
<script>
...
data() {
return {
activePlaces: [],
InputPlaceValue: ''
}
},
methods: {
placeChanged(places) {
let placeName = places.getPlace().name;
if(!this.activePlaces.includes(placeName)) this.activePlaces.push(placeName)
this.InputPlaceValue = ''
}
}
</script>
Надеюсь, вы можете помочь мне, спасибо.