1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| /**
| * 组件中开启 map.ts 生命周期
| * @copyright 火星科技 mars3d.cn
| * @author 火星吴彦祖 2022-02-19
| */
| import { inject, onBeforeMount, onBeforeUnmount } from "vue"
|
| export default function useLifecycle(mapWork: any): void {
| const getMapInstance = inject<any>("getMapInstance")
| onBeforeMount(() => {
| if (mapWork.onMounted) {
| const map = getMapInstance()
| mapWork.onMounted(map)
| }
| })
| onBeforeUnmount(() => {
| if (mapWork.onUnmounted) {
| mapWork.onUnmounted()
| }
| })
| }
|
|