uiwjs / react-baidu-map

基于 React 封装的百度地图组件,支持 React Hook,帮助你轻松的接入地图到 React 项目中。
https://uiwjs.github.io/react-baidu-map
MIT License
222 stars 22 forks source link

开发模式下使用鼠标滚轮放大地图抛出 Uncaught TypeError: Cannot read properties of undefined (reading 'style') #329

Open georgetian3 opened 4 months ago

georgetian3 commented 4 months ago

如何重现:

  1. 运行以下命令创建 React 项目并安装依赖:
    npx create-react-app example --template typescript
    cd example
    npm i @uiw/react-baidu-map
  2. 将以下代码粘贴到 src/App.tsx
    
    import './App.css';

import { Map, APILoader, } from '@uiw/react-baidu-map';

const Demo = () => ( <div style={{ width: '100%', height: '1000px', overflow: 'auto' }}>

);

function App() { return }

export default App;


3. 运行 `npm start`

当用户用鼠标滚轮放大地图会抛出 `Uncaught TypeError: Cannot read properties of undefined (reading 'style')` 并显示:

![image](https://github.com/uiwjs/react-baidu-map/assets/14836161/3447bf26-d969-4691-b4e6-d265161dd3e0)

如果 `npm run build` 并用生产版本运行不会出现这个问题。