【发布时间】:2017-12-17 03:34:13
【问题描述】:
当我尝试在 Ionic 2 应用程序中加载谷歌地图 API 时,我收到此错误:
未捕获(承诺中):TypeError:无法读取 null 的属性“firstChild” TypeError:无法在新 ug 的 Object._.pg (http://maps.google.com/maps/api/js?key=AIzaSyBOclEsMjwSHU-ec6OoGo6BB3FM91ixnJ0:85:391) 处读取 null 的属性 'firstChild'
这些是我的导入语句:
import { Platform, NavController, ModalController,IonicPage, NavParams }
from 'ionic-angular';
import {} from '@types/googlemaps';
import { GoogleMap, GoogleMapsEvent, LatLng } from '@ionic-native/google-
maps';
这些是我运行的命令:
1)npm install --save @ionic-native/google-maps 2)npm install @types/google-maps --save-dev --save-exact
<script src="http://maps.google.com/maps/api/js?key='AIzaSyBOclEsMjwSHU-
ec6OoGo6BB3FM91ixnJ0'"></script>
还与所有其他脚本引用一起添加到 index.html 中标记的末尾。 (如您所见,我还获得了一个 API 密钥,我添加了带单引号和不带单引号的密钥,但仍然出现相同的错误)
我使用 Sublime Text 3,在运行应用程序之前,我没有在代码中看到任何突出显示(下划线)的错误。
为什么会出现此错误,我该如何解决?
【问题讨论】:
标签: javascript google-maps typescript ionic2