current position:Home>16 ArcGIS API for JavaScript 4.18 a new development method based on ES modules @ ArcGIS / core

16 ArcGIS API for JavaScript 4.18 a new development method based on ES modules @ ArcGIS / core

2022-04-29 16:09:30X Beichen North

Write it at the front

With the front-end mainstream framework Vue and React The development of , Everyone is doing WebGIS When the project is developed, is it also in vue perhaps react Use... In projects ArcGIS API for JavaScript Well , We were in vue perhaps react Use... In projects ArcGIS API for JavaScript I always recommend it to you "esri-loader" Of AMD The way , The sample code is as follows ( Here's just a demonstration of React Use in projects ,Vue See the second part of the article for the usage of ):

// Use it directly esri-loader Of then() Method chain callback 
import React,{Component} from 'react';
import esriLoader from 'esri-loader';
import './App.css';
 
class App extends Component{
 
    state = {
 
    }
 
    componentDidMount = () => {
        const _self = this;
        const options = {
            url: 'https://js.arcgis.com/4.14/init.js', //  there API The address can be provided on the official website CDN, You can also configure the address for offline deployment here 
            css: 'https://js.arcgis.com/4.14/esri/themes/light/main.css'
        };
 
        esriLoader.loadModules([
            "esri/Map",
            "esri/views/MapView"], options) //  Pass in the class you want to use 
            .then(([Map,
                 

copyright notice
author[X Beichen North],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291427264669.html

Random recommended