The front end can also have configuration files.

How can I have a configuration file?

The simplest, is to write the configuration information in a JS file, the data format can be defined as JSON, directly read on the line.

Another option is to write the configuration information in a. Json file and use jquery to read it.

The config. Json file

{
  "map": {
    "apipath": "/ / 192.168.0.211 pubzy/arcgis_js_api / 4.10 /"."basemaps": [{"title": "Vector figure 1"."thumbnailUrl": "Images /map/ vector graph.gif"."type": "tile"."layer": "http://192.168.0.22:6080/arcgis/rest/services/GJHYDT84/MapServer"
      },
      {
        "title": "Vector diagram"."thumbnailUrl": "Images /map/ vector graph.gif"."type": "dynamic"."layer": "http://192.168.0.245:6080/arcgis/rest/services/GDHT/GDDZHT/MapServer"
      },
      {
        "title": "Image map"."thumbnailUrl": "Images /map/ image.gif"."type": "tile"."layer": "http://192.168.0.206:6080/arcgis/rest/services/HNJCZS/HNJCZSYXT/MapServer"},]."streamLayer": "http://192.168.0.195:6080/arcgis/rest/services/stream-service-newradar/StreamServer"."radarFeatureLayer": "http://192.168.0.100/arcgis/rest/services/Hosted/Radar_new/FeatureServer/0"."SliderTimeGap": 15,}}Copy the code

Then read and use in the page script:

let configJSON = '.. /config.json? t=' + new Date().getTime();
    
$.getJSON(configJSON, function (config) {
	//config is available
	mapcof = config.map;
});
Copy the code