我正在尝试用于react-leaflet显示地图。我使用了这个正在工作的小提琴中的代码,但是在我的电脑上我有这个输出
这是我的代码:
设备映射.js
import React from 'react'
import { Map, Marker, Popup, TileLayer } from 'react-leaflet';
export class DeviceMap extends React.Component {
  constructor() {
    super();
    this.state = {
      lat: 51.505,
      lng: -0.09,
      zoom: 13,
    };
  }
  render() {
    const position = [this.state.lat, this.state.lng];
    return (
      <Map center={position} zoom={this.state.zoom} scrollWheelZoom={false}>
        <TileLayer
          attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
          url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
        />
        <Marker position={position}>
          <Popup>
            <span>A pretty CSS3 popup. <br/> Easily customizable.</span>
          </Popup>
        </Marker>
      </Map>
    );
  }
}
export default DeviceMap
DeviceTabs.js
export class DeviceTabs extends React.Component {
  state = {
    index: 0
  };
  handleTabChange = (index) => {
    this.setState({ index })
  };
  render () {
    return (
      <Tabs index={this.state.index} onChange={this.handleTabChange}>
        <Tab label='Values'>
          <DeviceTable {...this.props} />
        </Tab>
        <Tab label='Map'>
          <div className={style.leaflet}>
            <DeviceMap />
          </div>
        </Tab>
      </Tabs>
    )
  }
}
样式文件
.leaflet {
  height: 300px;
  width: 100%;
}
控制台中没有错误,我不知道在哪里搜索。由于小提琴正在工作,因此它不是错误。我错过了什么 ?
