Skip to content

Commit 77fe601

Browse files
committed
切换问题
1 parent 7583079 commit 77fe601

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/marsgis/common/uses/use-lifecycle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
* @copyright 火星科技 mars3d.cn
44
* @author 火星吴彦祖 2022-02-19
55
*/
6-
import { inject, onMounted, onUnmounted } from "vue"
6+
import { inject, onBeforeMount, onBeforeUnmount } from "vue"
77

88
export default function useLifecycle(mapWork: any): void {
99
const getMapInstance = inject<any>("getMapInstance")
10-
onMounted(() => {
10+
onBeforeMount(() => {
1111
if (mapWork.onMounted) {
1212
const map = getMapInstance()
1313
mapWork.onMounted(map)
1414
}
1515
})
16-
onUnmounted(() => {
16+
onBeforeUnmount(() => {
1717
if (mapWork.onUnmounted) {
1818
mapWork.onUnmounted()
1919
}

src/marsgis/components/mars-work/mars-map.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @copyright 火星科技 mars3d.cn
88
* @author 火星吴彦祖 2022-02-19
99
*/
10-
import { computed, onBeforeUnmount, onMounted } from "vue"
10+
import { computed, onMounted } from "vue"
1111
import * as mars3d from "mars3d"
1212
import { getQueryString, isPc } from "@mars/utils/mars-util"
1313
import { $alert, $message } from "@mars/components/mars-ui/index"
@@ -131,18 +131,9 @@ function onMapLoad() {
131131
}
132132
}
133133
}
134-
135-
// 组件卸载之前销毁mars3d实例
136-
onBeforeUnmount(() => {
137-
if (map) {
138-
map.destroy()
139-
map = null
140-
}
141-
})
142134
</script>
143135

144136
<style lang="less">
145-
146137
/**cesium 工具按钮栏*/
147138
.cesium-viewer-toolbar {
148139
top: auto;

0 commit comments

Comments
 (0)