huiyan-fe / react-bmap

基于百度地图JavaScript API封装的React组件库
http://huiyan-fe.github.io/react-bmap
MIT License
498 stars 97 forks source link

Uncaught ReferenceError: BMap is not defined #20

Closed tommywu23 closed 6 years ago

tommywu23 commented 6 years ago

index.html

  <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=eBGR7XzaPhB5UbYARl3E7ksdkMdgrCw7"></script>

package.json

  "dependencies": {
    "react-bmap": "^1.0.55",

React Components

import { Map } from 'react-bmap'

...
<Map center={{lng: 116.402544, lat: 39.928216}} zoom="12" />

runtime error: Uncaught ReferenceError: BMap is not defined

hinikai commented 6 years ago

现在需要在页面中先引入jsapi的脚本,如

还未做异步加载地图jsapi处理

huangxiaohao commented 6 years ago

@hinikai 请问npm安装之后在哪里引入jsapi的脚本?我是npm安装之后运行报了ReferenceError: BMap is not defined的错

dingcaiying commented 6 years ago

@huangxiaohao 在html里加就行了:

...