我是 VueJS 和 Typescript 的新手。我正在使用 Google Maps Javascript API,但收到一个我不明白的 Typescript 错误。
这是我的代码
<script lang="ts">
import { } from 'googlemaps';
export default {
name: 'GoogleMap',
data () {
return{
message: '',
myCurrentLocation: 'unknown'
}
methods: {
...
updateCurrentLocation(address:string){
this.myCurrentLocation = address
}
编译器抛出错误 this.myCurrentLocation = address 上面写着
<块引用>“对任何值的不安全成员访问 .myCurrentLocation。”
当我将鼠标悬停在 VSCode 中的 this.myCurrentLocation 周围时,它表明 this.myCurrentLocation 被解释为“any”值。为什么会这样?我该如何解决这个问题。 我正在使用带有 Typescript 的 Quasar 框架。我相信它使用 VueJS 3