Parcourir la source

地图暴露静态只读map对象

HuangKai il y a 1 semaine
Parent
commit
c3df7e2a4b
1 fichiers modifiés avec 7 ajouts et 2 suppressions
  1. 7 2
      src/view/Map.js

+ 7 - 2
src/view/Map.js

@@ -106,7 +106,6 @@ L.Hash.prototype.update = function() {
  * Map component handles the whole map and associated widgets.
  */
 class MyMap extends Component {
-	static map;
 	constructor() {
 		super();
 
@@ -473,7 +472,13 @@ class MyMap extends Component {
 
 		window.mapUUID = this.props.uuid;
 
-		MyMap.map = this.elem.leafletElement;
+		//静态只读map
+		Object.defineProperty(MyMap, 'map', {
+			value: this.elem.leafletElement,
+			writable: false,
+			enumerable: false,
+			configurable: false
+		});
 
 		// URL hash for map
 		this._mapHash = new L.Hash(this.elem.leafletElement);