From ebbd788fbb2c0b45d4473798efc57eec8ba74a25 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 18 六月 2024 14:51:16 +0800 Subject: [PATCH] 版本更新至2.11.5 --- src/views/demo/charts/map/Gaode.vue | 67 +++++++++++++++------------------ 1 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/views/demo/charts/map/Gaode.vue b/src/views/demo/charts/map/Gaode.vue index 1b43fef..dfc1ad5 100644 --- a/src/views/demo/charts/map/Gaode.vue +++ b/src/views/demo/charts/map/Gaode.vue @@ -1,47 +1,42 @@ <template> <div ref="wrapRef" :style="{ height, width }"></div> </template> -<script lang="ts"> - import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; +<script lang="ts" setup> + import { ref, nextTick, unref, onMounted } from 'vue'; + import { useScript } from '@/hooks/web/useScript'; - import { useScript } from '/@/hooks/web/useScript'; + defineOptions({ name: 'AMap' }); + + defineProps({ + width: { + type: String, + default: '100%', + }, + height: { + type: String, + default: 'calc(100vh - 78px)', + }, + }); const A_MAP_URL = 'https://webapi.amap.com/maps?v=2.0&key=d7bb98e7185300250dd5f918c12f484b'; - export default defineComponent({ - name: 'AMap', - props: { - width: { - type: String, - default: '100%', - }, - height: { - type: String, - default: 'calc(100vh - 78px)', - }, - }, - setup() { - const wrapRef = ref<HTMLDivElement | null>(null); - const { toPromise } = useScript({ src: A_MAP_URL }); + const wrapRef = ref<HTMLDivElement | null>(null); + const { toPromise } = useScript({ src: A_MAP_URL }); - async function initMap() { - await toPromise(); - await nextTick(); - const wrapEl = unref(wrapRef); - if (!wrapEl) return; - const AMap = (window as any).AMap; - new AMap.Map(wrapEl, { - zoom: 11, - center: [116.397428, 39.90923], - viewMode: '3D', - }); - } + async function initMap() { + await toPromise(); + await nextTick(); + const wrapEl = unref(wrapRef); + if (!wrapEl) return; + const AMap = (window as any).AMap; + new AMap.Map(wrapEl, { + zoom: 11, + center: [116.397428, 39.90923], + viewMode: '3D', + }); + } - onMounted(() => { - initMap(); - }); - - return { wrapRef }; - }, + onMounted(async () => { + await initMap(); }); </script> -- Gitblit v1.9.3