Nuxt 打字稿 - 类型“CombinedVueInstance”上不存在属性“map”

时间:2021-05-10 14:52:32

标签: typescript vue.js types nuxt.js

我正在尝试将 nuxt 与 typescript 一起使用,但在地图(mapbox 对象)上出现错误

我在我的数据中定义它

data() {
  return {  
    map: null,
  }
}

并初始化它。

mounted() {
  this.map = new mapboxgl.Map({
    /* option in here */
  })
}

我知道它是一个复杂的对象,所以可以使用“任何”类型,但我如何摆脱错误?

Property 'map' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<

0 个答案:

没有答案