Map container is being reused by another instance
由于自己使用vue封装了leaflet成公用组件,导致切换到别的页面(不需要leaflet)导致报错Map container is being reused by another instance;
解决方法:this.map = null;//将当前组件下的的map置空;以及引入的组件 this.$refs.ForeMap.map = null//给你自己引入的组件加一个ref获取map将它置空
beforeDestroy() {
if (this.map) {
this.map.remove()
this.map = null;//将当前的map置空
this.$refs.ForeMap.map = null//给你自己引入的组件加一个ref获取map将它置空
}
},