ArcGIS API for JavaScript 4.18+基于ES Modules的本地化设置@arcgis/core local

ArcGIS API for JavaScript 4.18以后的版本4.18 4.19 4.20 4.21 4.22支持ES Modules模式了,默认的API是访问CDN的,内网本地化修改,竟然摸索了好久,分享出来。最终还是满读官网的参考文档解决的,具体链接:https://developers.arcgis.com/javascript/latest/es-modules/
https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app,GitHub上React示例代码的本地化为例,步骤如下:

步骤:
1、npm或者yarn添加@arcgis/core包
2、将./node_modules/@arcgis/core/assets文件夹复制到public下
3、App.js

import esriConfig from "@arcgis/core/config.js";
esriConfig.assetsPath = "./assets";

4、index.css

@import "@arcgis/core/assets/esri/themes/light/main.css";

5、目录结构
目录结构
App.js 代码

import React, { useRef, useEffect } from "react";
import Bookmarks from '@arcgis/core/widgets/Bookmarks';
import Expand from '@arcgis/core/widgets/Expand';
import MapView from "@arcgis/core/views/MapView";
import WebMap from "@arcgis/core/WebMap";

import "./App.css"; 

import esriConfig from "@arcgis/core/config.js";
esriConfig.assetsPath = "./assets";

index.css

@import "@arcgis/core/assets/esri/themes/light/main.css";

html,
body,
#root {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

6、以下为官方文档的截图:
官网依据1
官网依据2
默认配置是CDN

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Higer2008

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值