小编Bou*_*nee的帖子

google api 已经出现在 React 应用程序中

“谷歌 API 已经呈现”

屏幕截图错误说明

1.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=GOOGLE API KEY0&libraries=places"></script>
    <script>
        function init() {

            var options = {
              types: ['(cities)'],
              componentRestrictions: {country: "au"}
            };

            var input = document.getElementById('citySearch');
            var autocomplete = new google.maps.places.Autocomplete(input,options);
        }

        google.maps.event.addDomListener(window, 'load', init);
    </script>
Run Code Online (Sandbox Code Playgroud)

2

  return (
    <div className="googleMapContainer">
      {console.log(window.google)}
      <LoadScript googleMapsApiKey={googleApiKey}>
        <div className="googleMap">
          <GoogleMap
Run Code Online (Sandbox Code Playgroud)

怎么处理这个?一个 api 密钥位于 index.html 中,另一个尝试使用 api 密钥作为组件 react-google-maps 的 props

api key reactjs

6
推荐指数
2
解决办法
9268
查看次数

标签 统计

api ×1

key ×1

reactjs ×1