Front end configuration file

The front end can also have configuration files.

How do you have a configuration file?

The simplest is to write the configuration information in the js file, the data format can be defined as json, just read it.

There is another way, that is
Write the configuration information in a .json file and read it with jquery.

Config.json file

{
  "map": {
    "apipath": "//192.168.0.211/pubzy/arcgis_js_api/4.10/",
    "basemaps": [      
      {
        "title": "Vector 1",
        "thumbnailUrl": "images/map/vector.gif",
        "type": "tile",
        "layer": "http://192.168.0.22:6080/arcgis/rest/services/GJHYDT84/MapServer"
      },
      {
        "title": "vector",
        "thumbnailUrl": "images/map/vector.gif",
        "type": "dynamic",
        "layer": "http://192.168.0.245:6080/arcgis/rest/services/GDHT/GDDZHT/MapServer"
      },
      {
        "title": "image map",
        "thumbnailUrl": "images/map/image map.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,
  }
}

Then read and use in the page script:

let configJSON = '../config.json?t=' + new Date().getTime();
    
$.getJSON(configJSON, function (config) {
	//config got it.
	mapcof = config.map;
});

Intelligent Recommendation

Front-end download file configuration, json file export.

Export csv file Apple system and windows system can open the file directly (recommended) Export html text windows can be opened directly, Apple system needs to modify the file suffix named .xls to ope...

Detailed vue-cli2.0 configuration file -- Qi Yufei front end

webpack.base.conf.js has some basic elements including, similar to the usual webapck.config.js. webpack.dev.conf.js This configuration will be used for our native development. webpack.prod.conf.js The...

nginx front end load balancing master configuration file

cat /usr/local/nginx/conf/nginx.conf Reproduced in: https: //blog.51cto.com/wujianwei/2082604...

Some processing of running commands in front-end project configuration file script

Compatibility handling of running project commands in different operating systems When using NODE_ENV = production to set environment variables, most Windows command prompts will be blocked, but ubunt...

Configuration of web.xml file front-end controller in Spring MVC

The front-end controller in Spring MVC isDispatcherServlet, which inherits the abstract class HttpServlet. The front-end controller is the centralized access point of Spring MVC, and its main responsi...

More Recommendation

Find the nginx configuration file of the front-end port number through finalshell

Step 1: Create and connect to the service If you are not clear, you can refer to the article: Step 2: Find the nginx configuration file Command: netstat -nltp |grep port number   pwdx process number...

VSCode builds the configuration file of the vue front-end development project-launch.json

Description: launch.json configuration file settings.json file (the terminal will not appear garbled when compiling)  ...

Web front-end file sorting and classification, environmental software configuration

Individual document classification Preface File classification Environment software configuration surroundings Essential extensions for Google Chrome VScode basic configuration Other commonly used sof...

Front end and mobile development --- Webpack --- WebPack configuration file

webpack the goal: Learn profiles using WebPack Will specify package mode and learn about the difference between the two packages Will specify the entrance, export file Set DevTool The zero configurati...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top