Skip to content

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

Description

@georgetian3

如何重现:

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

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

const Demo = () => (
  <div style={{ width: '100%', height: '1000px', overflow: 'auto' }}>
    <APILoader akay="eYpCTECSntZmw0WyoQ7zFpCRR9cpgHFG">
      <Map
        zoom={13}
        style={{ height: 1000 }}
        enableScrollWheelZoom={true}
        enableContinuousZoom={true}
      >
      </Map>
    </APILoader>
  </div>
);


function App() {
  return <Demo></Demo>
}

export default App;
  1. 运行 npm start

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

image

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions