我很难在屏幕上渲染我的谷歌地图。我见过this question,但即使这样做也解决不了我的问题。
我所拥有的:
import React from 'react'
import GoogleMap from 'google-map-react';
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import s from './CarMap.css'
class MoobieMap extends React.Component {
constructor(props){
super(props)
}
render() {
return (
<div className={s.map}>
<GoogleMap apiKey={API_KEY} center={{lat: -23.5925282, long: -46.6891377}} zoom={3}/>
</div>
)
}
}
export default withStyles(s)(MoobieMap)和:
import React from 'react'
import Layout from '../../components/Layout'
import MoobieMap from './CarMap'
const title = 'Mapa de carros'
export default {
path: '/car-map',
async action() {
return {
title,
chunk: 'component',
component: <Layout title={title}><MoobieMap /></Layout>,
}
},
}和css:
.map {
width: 100%;
height: 400px;
}我也在使用工具包。我的DOM看起来是这样的:

我的控制台中也没有js错误。
我在这里错过了什么?谢谢!
编辑:

发布于 2017-07-01 20:33:40
尝试只导入css wihtout,并将它们命名为:
import React from 'react'
import GoogleMap from 'google-map-react';
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import './CarMap.css'
class MoobieMap extends React.Component {
constructor(props){
super(props)
}
render() {
return (
<div>
<GoogleMap apiKey={API_KEY} center={{lat: -23.5925282, long: -46.6891377}} zoom={3} className="map"/>
</div>
)
}
}
export default withStyles(s)(MoobieMap)MoobieMap和样式之间的连接是什么?
我希望它有帮助,请告诉我,你的.map有宽度和高度声明.
https://stackoverflow.com/questions/44864037
复制相似问题