-1

我正在使用服务作品来预取 Google Maps Javascript SDK。因为服务人员使用fetch我不断收到此错误 -

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

如何在谷歌地图 SDK 上启用 CORS?

更新

我正在使用sw-toolbox,在我的服务人员中我有以下代码 -</p>

import toolbox from 'sw-toolbox'
      toolbox.precache([
        '/',
        '/bundle.js',
        '/manifest.json',
        '/ola_icon.png',
        '/favicon.png',
        'https://maps.googleapis.com/maps/api/js?key=myapikey&callback=initMap'
      ])
4

1 回答 1

0

这里有一些关于使用 CORS 访问 Google API 的文档。

于 2016-04-21T17:43:40.020 回答