【问题标题】:types googlemaps index.d.ts is not a module error message类型 googlemaps index.d.ts 不是模块错误消息
【发布时间】:2019-08-31 10:25:59
【问题描述】:

我似乎无法解决此错误,尝试在我的应用中实现 google 自动完成以进行地点搜索。

我已经尝试了大多数在线建议来解决此问题 打字安装 dt~google.maps --global npm install typings --global npm install @types/googlemaps --save-dev npm install @agm/core --save npm install ngx-google-places-autocomplete npm i -S google-places-autocomplete-service npm install @google/maps

我最初收到此错误: 无法导入类型声明文件。考虑导入“googlemaps”而不是“@types/googlemaps”。

然后在导入 googlemaps 后出现以下错误: node_modules/@types/googlemaps/index.d.ts' 不是模块。

奇怪的是在我的打字 -> 全局 -> google.maps -> index.d.ts 文件导出类 Map 有一个错误,指出存在重复的标识符。

我检查了,该命名空间也在 node_modules -> @types -> googlemaps -> index.d.ts 中。

所以看起来命名空间是在多个文件中声明的。我不确定它应该在哪里。

【问题讨论】:

    标签: angular google-maps npm ionic4


    【解决方案1】:

    我卸载了所有东西并使用了以下代码......更简单。

    我只需要安装 ngx-google-places-autocomplete

      public handleCityChange(cities: any) {
        this.location = cities.formatted_address;
        console.log('location', this.location);
      }
                    <input ngx-google-places-autocomplete [options]='options' #placesRef="ngx-places" (onAddressChange)="handleDesiredCityChange($event)"/>

    【讨论】:

      猜你喜欢
      • 2018-12-07
      • 2017-01-09
      • 2018-12-05
      • 2019-04-18
      • 2018-11-10
      • 2020-02-23
      • 2016-11-10
      • 2020-01-18
      • 2022-12-16
      相关资源
      最近更新 更多