【发布时间】:2019-06-26 05:05:29
【问题描述】:
我遇到了一个运行时错误,它在我的 Angular 应用程序中为我提供了 defaultView 的堆栈跟踪,它阻止我继续我的项目。
错误: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'defaultView' of undefined
TypeError: Cannot read property 'defaultView' of undefined
我已经用谷歌搜索了这个,但没有一个问题有角度。所以我认为这是第一个关于 defaultView 的带角度的。
我有一些代码可以获取地址并将标记输出到地图上。我收到了来自https://developers.google.com/maps/documentation/javascript/geocoding的错误
Stackblitz 中的代码:https://stackblitz.com/edit/angular-gib2mq。
根文件夹中的index.d.ts 使导入语句起作用:import { } from 'googlemaps';
declare module "googlemaps";
我还通过npm install --save @types/googlemaps 安装了@types/googlemaps
我希望错误消失,但每次运行我的应用程序时都会发生。
谢谢!
【问题讨论】:
-
尝试
import * as googlemaps from 'googlemaps';代替您的导入语句 -
上面写着
'googlemaps' is declared but its value is never read编辑:现在我使用它时它就崩溃了:找不到模块。 -
这是一个
tslint错误,您的实际错误是否已解决? -
不,没有解决。编辑:我需要这个吗? npmjs.com/package/tslint-angular
-
当我尝试使用我的 API 密钥时,您的请求没有被触发
标签: angular google-maps geolocation angular-google-maps