源码
新建文件夹Exp01,新建一个Demo01.html源码,拷贝build文件夹到Exp01文件夹。

编写网页源码如下:

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Use correct character set. -->
    <meta charset="utf-8" />
    <!-- Tell IE to use the latest, best version. -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
    />
    <title>Hello World!</title>
    <script src="../Build/CesiumUnminified/Cesium.js"></script>
    <style>
      @import url(../Build/CesiumUnminified/Widgets/widgets.css);
      html,
      body,
      #cesiumContainer {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
      }
    </style>
  </head>
  <body>
    <div id="cesiumContainer"></div>
    <script>
      const viewer = new Cesium.Viewer("cesiumContainer",{
        geocoder:true,
        homeButton:true,
        sceneModePicker:true,
        baseLayerPicker:true,
        navigationHelpButton:true,
        animation:false,
        timeline:false,
        fullscreenBUtton:true,
      });
    </script>
  </body>
</html>

发布
以管理员身份运行CMD,在其中输入命令如黄色部分,采样http-server进行网页发布。

D:\CesiumExp\CesiumJS>cnpm install http-server -g
[npminstall:get:error] GET https://registry.npmmirror.com/binary-mirror-config/latest ConnectTimeoutError: Connect Timeout Error after 5 reties, status: -1, headers: {}
[npminstall:get:error] GET https://registry.npmmirror.com/binary-mirror-config/latest ConnectTimeoutError: Connect Timeout Error after 5 reties, status: -1, headers: {}
^C
D:\CesiumExp\CesiumJS>cnpm install http-server -g
Downloading http-server to C:\Users\yhexie\AppData\Roaming\npm\node_modules\http-server_tmp
Copying C:\Users\yhexie\AppData\Roaming\npm\node_modules\http-server_tmp.store\http-server@14.1.1\node_modules\http-server to C:\Users\yhexie\AppData\Roaming\npm\node_modules\http-server
Installing http-server’s dependencies to C:\Users\yhexie\AppData\Roaming\npm\node_modules\http-server/node_modules
[1/13] mime@^1.6.0 installed at node_modules.store\mime@1.6.0\node_modules\mime
[2/13] minimist@^1.2.6 installed at node_modules.store\minimist@1.2.8\node_modules\minimist
[3/13] http-proxy@^1.18.1 installed at node_modules.store\http-proxy@1.18.1\node_modules\http-proxy
[4/13] secure-compare@3.0.1 installed at node_modules.store\secure-compare@3.0.1\node_modules\secure-compare
[5/13] basic-auth@^2.0.1 installed at node_modules.store\basic-auth@2.0.1\node_modules\basic-auth
[6/13] opener@^1.5.1 installed at node_modules.store\opener@1.5.2\node_modules\opener
[7/13] url-join@^4.0.1 installed at node_modules.store\url-join@4.0.1\node_modules\url-join
[8/13] corser@^2.0.1 installed at node_modules.store\corser@2.0.1\node_modules\corser
[9/13] he@^1.2.0 installed at node_modules.store\he@1.2.0\node_modules\he
[10/13] chalk@^4.1.2 installed at node_modules.store\chalk@4.1.2\node_modules\chalk
[11/13] html-encoding-sniffer@^3.0.0 installed at node_modules.store\html-encoding-sniffer@3.0.0\node_modules\html-encoding-sniffer
[12/13] union@~0.5.0 installed at node_modules.store\union@0.5.0\node_modules\union
[13/13] portfinder@^1.0.28 installed at node_modules.store\portfinder@1.0.32\node_modules\portfinder
All packages installed (39 packages installed from npm registry, used 2s(network 2s), speed 254.77KB/s, json 13(68.69KB), tarball 471.93KB, manifests cache hit 26, etag hit 26 / miss 2)
[http-server@14.1.1] link C:\Users\yhexie\AppData\Roaming\npm\http-server@ -> C:\Users\yhexie\AppData\Roaming\npm\node_modules\http-server\bin\http-server

D:\CesiumExp\CesiumJS>cd D:\CesiumExp\Exp01

D:\CesiumExp\Exp01>http-server -g
Starting up http-server, serving ./

http-server version: 14.1.1

http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: true
Serve Brotli Files: false
Default File Extension: none

Available on:
http://192.168.126.1:8080
http://192.168.209.1:8080
http://192.168.1.5:8080
http://127.0.0.1:8080
Hit CTRL-C to stop the server

复制任意一个网址访问