有一个包含此元素的 HTML 表单:
var control = container.getElementById('AutoComplete');
var input = /** @type {!HTMLInputElement} */ (control);
console.log("input: ", input); //Output: <input type="text" id="AutoComplete" placeholder="--" class="block_input" autocomplete="off">
autocomplete = new google.maps.places.Autocomplete(input, {
types: ['geocode']
});
<html>
<div id="input_address">
<div class="element">
<label class="block_label">Адрес</label>
</div>
<div class="element">
<input type="text" id="AutoComplete" placeholder="--" class="block_input"></input>
</div>
</div>
</html>
我有一个错误:
not an instance of HTMLInputElement
我该如何解决这个问题?
最佳答案
我也遇到了同样的问题,这个方法有效。
let searchInputField = document.getElementsByClassName('search-form')[0].getElementsByTagName('input')[0];
let autocomplete = new google.maps.places.Autocomplete(searchInputField);
关于javascript - Google Places API 无效值错误 : not an instance of HTMLInputElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42695109/