Parcourir la source

取消百度地图加载

zhouy il y a 3 semaines
Parent
commit
0ac0c62ff6

+ 6 - 2
uas-office-web/wxuasapproval/src/components/map/MapSearch.jsx

@@ -28,6 +28,10 @@
  
    componentDidMount () {
      this.searchBar.focus()
+       if (!window.BMap) {
+           console.warn('百度地图未加载,搜索功能将不可用')
+           return
+       }
      const { BMap } = window
      let that = this
      this.localSearch = new BMap.LocalSearch(this.map,
@@ -61,9 +65,9 @@
        center,
        searchList,
      } = this.state
- 
+       const showSearchResults = !!window.BMap;
      const searchItems = []
-     if (searchList) {
+     if (showSearchResults && searchList) {
        searchList.forEach((item, index) => {
          searchItems.push(
             <div