yue1123 / vue3-baidu-map-gl

🎉百度地图 GL版 Vue3 组件库,baidu map gl components libary based on Vue3.0
https://yue1123.github.io/vue3-baidu-map-gl/
MIT License
357 stars 41 forks source link

你好,这个不用了怎么销毁呢 #93

Closed badspider7 closed 2 hours ago

badspider7 commented 2 hours ago

你好,这个库很好用,提高了很多效率,给一大大的好评❤️。 但是有个问题我通过 initd这个事件拿到 map, BmapGL, instance ,这三个都没有看到有distory方法欸,想知道是直接拿到dom删掉就可以了吗,那一些事件也会同时注销掉吗。

badspider7 commented 2 hours ago

因为我一个页面可能有多个实例这样子,不销毁的话内存占用有点大

yue1123 commented 2 hours ago

组件内部是做了在组件卸载时的map实例销毁,你只需要控制好组件的卸载时机即可

badspider7 commented 2 hours ago

ok,哈哈哈回复的好快

yue1123 commented 2 hours ago

🤣刚好看到

badspider7 commented 2 hours ago

刚刚看了下,也可以通过组件暴露出来的getMapInstance方法拿到map,然后调用map.distory()

yue1123 commented 1 hour ago

是的,但这个api主要是给map组件下子元素使用的,正常使用不需要自己调用destroy