reactjs - 谷歌 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>
2
return (
<div className="googleMapContainer">
{console.log(window.google)}
<LoadScript googleMapsApiKey={googleApiKey}>
<div className="googleMap">
<GoogleMap
如何处理?一个 api 密钥在 index.html 中,另一个正在尝试使用 api 密钥作为组件 react-google-maps 的道具
解决方案
在代码中尝试<GoogleMap />
不使用 2。在此处<LoadScript />
查看更多信息
推荐阅读
- node.js - Node.js 中的二维圆形碰撞反应
- javascript - 如何避免与 Jest 的时间耦合?
- c++ - 如何在 boost::filesystem 中调试此段错误
- javascript - Facebook 页面帖子嵌入选项缺失
- rpa - RPA 备用等待命令选项
- django - 我的网站的主应用程序在运行时没有被查看
- windows - 需要帮助了解 VSCode 如何处理环境变量
- c++ - 将数据从向量传输到队列并关闭
- powershell - 如何使用 PowerShell 导入文件,并将所有现有的占位符变量替换为脚本中定义的变量?
- python - Python 3.X Pandas - ValueError:必须仅通过布尔值传递 DataFrame