在我尝试在项目中使用 google 变量后,任何人都可以帮我解决这个错误,我进入了 ionic 3 应用程序,
npm install --save @types/google-maps
将以下内容添加到我的 package.json 中:
"@types/google-maps": "^3.2.0",
我也声明了 var google;
and did typings install dt~google.maps --global
然后我看到了这个解决方案并尝试了它,但这也不起作用(注意我生成了一个ios密钥和android密钥)
试过这个找不到命名空间“google” https://stackoverflow.com/questions/41359496/cannot-find-namespace-google
离子科尔多瓦插件添加https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps--variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE" $ npm install --save @ionic-native/google-maps
我的 map.ts 的要点是拍摄此错误:
https://gist.github.com/abdulfatah-ah1407281/25bc95352d0b1ba8e02b7d1e55cc7779 https://gist.github.com/abdulfatah-ah1407281/25bc95352d0b1ba8e02b7d1e55cc7779
当我运行离子服务时出错:
Cannot find namespace 'google'.
C:/Users/pkhon/Desktop/k/ItBroken/src/components/map/map.ts
private map: google.maps.Map;
public isMapIdle:boolean;
你没有提到这一点,但我猜你使用的是Windows。您正在使用 ionic,并且在某些情况下存在平台差异(不确定谁负责,ionic 还是 typescript),其中相同tsconfig.json
文件将在 Macos(也许还有 Linux)上运行,但在 Windows 中不能运行,除非显式添加typeRoots
进入到compilerOptions
你的tsconfig.json
, 像这样:
// tsconfig.json
{
"compilerOptions": {
// ... other stuff
"typeRoots": [ 'node_modules/@types' ]
}
// ... other stuff
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)