diff --git a/src/components/cluster.vue b/src/components/cluster.vue index 48cdbd6..5699e7e 100644 --- a/src/components/cluster.vue +++ b/src/components/cluster.vue @@ -103,11 +103,14 @@ export default buildComponent({ }, beforeUnmount() { /* Performance optimization when destroying a large number of markers */ - this.$children.forEach((marker) => { - if (marker.$clusterObject === this.$clusterObject) { - marker.$clusterObject = null - } - }) + if (this.$children && this.$children.length) { + this.$children.forEach((marker) => { + if (marker.$clusterObject === this.$clusterObject) { + marker.$clusterObject = null + } + }) + } + if (this.$clusterObject) { this.$clusterObject.clearMarkers()