百度地圖API name未定義[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.


直接上html

 1 <template>
 2 <baidu-map class="map" center="中國">
 3   <bml-marker-clusterer :averageCenter="true">
 4     <bm-marker v-for="marker of markers" :position="{lng: marker.lng, lat: marker.lat}"></bm-marker>
 5   </bml-marker-clusterer>
 6 </baidu-map>
 7 </template>
 8 
 9 <script>
10 import {BmlMarkerClusterer} from 'vue-baidu-map'
11 export default {
12   data () {
13     // 插入 10 個隨機點
14     const markers = []
15     for (let i = 0; i < 10; i++) {
16       const position = {lng: Math.random() * 40 + 85, lat: Math.random() * 30 + 21}
17       this.markers.push(position)
18     }
19     return {
20       markers
21     }
22   },
23   components: {
24     BmlMarkerClusterer
25   }
26 }
27 </script>

 


main.js部分
1     import BaiduMap from 'vue-baidu-map';
2     import {BmlMarkerClusterer} from 'vue-baidu-map';
3     //引入點聚合
4    Vue.component('bml-marker-cluster', BmlMarkerClusterer);
5    //引入百度地圖
6   Vue.use(BaiduMap, {
7     ak: 'youAK'
8   });

 

這種寫法是官網給的demo,不過會報錯,錯誤信息為[Vue warn]: Unknown custom element: <bml-marker-clusterer> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
 
原因是 blm-marker-clusterer寫法有問題,改為blm-marker-cluster即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 vue報錯[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.問題的解決方法 at src/views/index/"> [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ---> at src/views/index/ Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.解決方法 Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. vue組件注冊錯誤:Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. vue引入組建報錯Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in VUE報錯解決方法 Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM