【发布时间】:2018-12-30 08:30:23
【问题描述】:
我尝试使用Google Places Autocomplete API 填充Vuetify Autocomplete Component,如下所示:
<template>
<v-autocomplete
ref="autocomplete"
label="Location"
>
</v-autocomplete>
</template>
<script>
export default {
mounted() {
var autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(this.$refs.autocomplete),
{types: ['geocode']})
}
}
</script>
但是,在浏览器的开发者控制台中,却抛出了一个错误:
InvalidValueError: 不是 HTMLInputElement 的实例
我的猜测是 v-autocomplete 不是 HTMLInputElement 类型。
(不仅v-autocomplete 是这种情况:用v-input 替换它也会导致同样的错误。)
有没有办法让v-autocomplete 填充 Google Places Autocomplete API,比如手动将其设置为 HTMLInputElement 的实例?
【问题讨论】:
标签: javascript vue.js autocomplete google-places-api vuetify.js