Pārlūkot izejas kodu

加载地图移至App

HuangKai 1 nedēļu atpakaļ
vecāks
revīzija
8671a978ae
1 mainītis faili ar 17 papildinājumiem un 0 dzēšanām
  1. 17 0
      src/view/App.js

+ 17 - 0
src/view/App.js

@@ -310,4 +310,21 @@ export default class App {
 		PubSub.publish('body.data.update', cards);
 	  }
 	}
+
+	/** * 加载地图文件 * * 
+	 * @param {String} url - 地图文件路径 * 
+	*/
+	loadMap(url) {   
+		fetch(url)
+			.then(res => res.text())
+			.then(data => {
+				// 处理获取的数据
+				let json = JSON.parse(data);
+				PubSub.publish("body.draw.loaded", json);
+			})
+			.catch(error => {
+				// 处理错误
+				console.error('There was a problem with the fetch operation:', error);
+			});
+	}
 }