I am trying to implement Google Places Autocomplete in Vue.js.
The API states that the Autocomplete
class first takes an inputField:HTMLInputElement
, as used in their example:
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['geocode']});
Since we cannot pass elements around by their ID's in Vue.js? How would this be achieved, and what kind of construct would we pass?
e.g. the following code fails
<template>
<input id="autocomplete" placeholder="Enter your address" type="text"></input>
</template>
<script>
export default {
created() {
var autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['geocode']});
}
}
</script>
with error:
InvalidValueError: not an instance of HTMLInputElement