import React from 'react' // 导入样式 // import './index.scss' import styles from "./index.module.scss" import NavHeader from '../../components/NavHeader'; export default class Map extends React.Component { componentDidMount() { var map = new window.BMapGL.Map("container"); // 创建地图实例 var point = new window.BMapGL.Point(116.404, 39.915); // 创建点坐标 map.centerAndZoom(point, 15); // 初始化地图,设置中心点坐标和地图级别 } render() { return ( <div className={styles.map}> {/* 顶部导航栏组件 */} <NavHeader onLeftClick={()=>{ }}> 地图找房 </NavHeader> <div id="container" className={styles.container}></div> </div> ) } }
运行结果