-1
我正在使用谷歌地圖與反應。但是,當我跑我的項目,我得到了Polygon.js錯誤文件谷歌地圖與ReactJs
TypeError: Cannot read property 'Component' of undefined
TypeError: Cannot read property 'array' of undefined
請讓我知道爲什麼嗎?
這是剪斷代碼和圖片描述錯誤:
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types'
import { GoogleAPIWrapper, InfoWindow, Marker } from 'google-maps-react'
export class MapContainer extends React.Component {
componentDidMount() {
this.loadMap();
}
loadMap() {
let map = new window.google.maps.Map(document.getElementById('map'), {
center: { lat: -33.8688, lng: 151.2195 },
zoom: 13,
mapTypeID: 'roadmap'
})
}
render() {
const style = {
width: "100%",
hight: "100%"
};
return (
<div id='map'>
</div>
);
}
}
export default GoogleAPIWrapper(
{
apiKey: "MY_KEY",
}
)(MapContainer);
是吧'GoogleAPIWarapper'或'GoogleAPIWrapper'? AND不是你在構造函數中綁定'loadMap()'嗎? – Dane
嗨丹尼! Sr,我是GoogleAPIWarapper(GoogleAPIWrapper)中的錯誤類型。我已經得到新的錯誤「類型錯誤:對象(...)不是一個函數」在行:出口默認GoogleAPIWrapper( { apiKey:「MY_KEY」 } )(MapContainer); – Foxes