百度地图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