From 9a5ad4f42f936fa5b36cd039a670d36e6f70a568 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期五, 15 三月 2024 11:48:04 +0800
Subject: [PATCH] feat:交通事故指数接口对接

---
 src/views/daoAnOffice/center/map.vue |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/views/daoAnOffice/center/map.vue b/src/views/daoAnOffice/center/map.vue
index 3600a7d..12542ee 100644
--- a/src/views/daoAnOffice/center/map.vue
+++ b/src/views/daoAnOffice/center/map.vue
@@ -42,7 +42,7 @@
 </template>
 
 <script setup>
-import { onMounted, ref,getCurrentInstance } from 'vue';
+import { onMounted, ref, getCurrentInstance, nextTick } from 'vue';
 import AMapLoader from '@amap/amap-jsapi-loader';
 
 import DialogType1 from './dialog/dialog-type1.vue';
@@ -80,7 +80,7 @@
 // dialog闆嗗悎
 const dialogList = ref({});
 // 鑾峰彇褰撳墠瀹炰緥
-const {ctx} = getCurrentInstance();
+let ctx = null;
 
 let mapInstance = null;
 let trafficLayer = null;;
@@ -202,7 +202,7 @@
 // 杩囨护鍥惧垪
 const filterLegend = (item) => {
   const { icon, positions, type } = item;
-  const dialog = dialogList.value[type].$refs.dialog;
+  const dialog = dialogList.value[type]._.refs.dialog;
   const tempList = [];
   positions.map(position => {
     const markerIcon = createIcon(icon);
@@ -278,13 +278,16 @@
 
 // 寮圭獥涓庣粍浠舵槧灏�
 const mapComponentInstance = () => {
-  legendList.value.map((item) => {
-    dialogList.value[item.id] = ctx.$refs[`dtype${item.id}`];
+  console.log(ctx);
+  legendList.value.forEach((item) => {
+    dialogList.value[item.id] = ctx._.refs[`dtype${item.id}`];
   })
 }
 
 
 onMounted(() => {
+  // 鑾峰彇褰撳墠瀹炰緥
+  ctx = getCurrentInstance().ctx;
   AMapLoader.load({
     key: "2898109c22191c3969957500934169dc", //鐢宠濂界殑 Web 绔紑鍙戣�� Key锛岄娆¤皟鐢� load 鏃跺繀濉�
     version: "2.0", //鎸囧畾瑕佸姞杞界殑 JS API 鐨勭増鏈紝缂虹渷鏃堕粯璁や负 1.4.15
@@ -354,7 +357,9 @@
       // 鍒涘缓infowindow
       createInfoWindow();
       // 鏄犲皠缁勪欢
-      mapComponentInstance();
+      nextTick(() => {
+        mapComponentInstance();
+      })
     })
     .catch((e) => {
       console.log(e);

--
Gitblit v1.8.0