share.vue 935 Bytes
<template>
  <div>
    <mapContent ref="mapContentRefs">
      <template #mapBox>
        <div id="shareContainer" class="map-container"></div>
      </template>
    </mapContent>
    <slot></slot>
  </div>
</template>

<script>
import { ref, defineComponent, onMounted } from "vue";
import mapContent from "@/components/mapContent.vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "../constant";
export default defineComponent({
  name: "SharePage",
  components: {
    mapContent,
  },
  setup() {
    const mapContentRefs = ref(null);
    onMounted(() => {
      AMapLoader.load({
        key: CONSTANT.MAP_KEY,
        version: "1.4.8",
        plugins: CONSTANT.MAP_PLUGINS,
      }).then((AMap) => {
        window.AMap = AMap;
        mapContentRefs.value.initMap("shareContainer");
      });
    });
    return {
      mapContentRefs,
    };
  },
});
</script>
<style lang="scss" scoped></style>