首页 文章

在离子3应用程序中找不到命名空间'google'

提问于
浏览
2

在我尝试在我的项目中使用google变量之后,任何人都可以帮我解决这个错误我进入我的离子3应用程序

npm install --save @ types / google-maps

它将以下内容添加到我的package.json中:

“@ types / google-maps”:“^ 3.2.0”,

我也宣布声明var google;

并做了 typings install dt~google.maps --global

然后我看到了这个灵魂并尝试了但是这也没有用(注意我生成了一个ios键和android键)尝试了这个Cannot find namespace 'google'

ionic cordova插件添加https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps - 变量API_KEY_FOR_ANDROID =“YOUR_ANDROID_API_KEY_IS_HERE” - 变量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

运行离子发球时出错:

Cannot find namespace 'google'.
C:/Users/pkhon/Desktop/k/ItBroken/src/components/map/map.ts
private map: google.maps.Map;
public isMapIdle:boolean;

1 回答

  • 3

    你没有猜测你是否正在使用离子,并且在某些情况下(不确定谁是负责人,离子或打字稿)存在平台差异,其中相同的 tsconfig.json 文件将在macos(可能是linux)上运行,但不在没有窗口的情况下明确地将 typeRoots 条目添加到 tsconfig.jsoncompilerOptions 中,如下所示:

    // tsconfig.json
    {
      "compilerOptions": {
        // ... other stuff
        "typeRoots": [ 'node_modules/@types' ]
      }
      // ... other stuff
    }
    

相关问题